LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-30-2011, 03:54 PM   #1
expert_vision
LQ Newbie
 
Registered: Mar 2011
Posts: 13

Rep: Reputation: 0
Question Run script on a different shell than the default one


I need cron to run a script that manipulates huge numbers, and shell can't. So I installed bash and if I run the script from console it's ok. But when cron launch it no matter what indication I put on the first line (i.e. #!/opt/bin/bash) is still uses default shell.
Bash is on a remote location so I can't change user default shell in /etc/passwd. Besides I'm not sure of the compatibility with other shell scripts.
For instance if I run this
Code:
#!/opt/bin/bash
var=`expr 14680064000 / 1024 / 1024`
echo $var > /mnt/output
in console I get 14000
and with cron I get 2047.

p.s.:I did change shell path in crontab .. but still nothing. I even tried "screen -rms /opt/bin/bash /mnt/test" in cron. I'm clueless ...
 
Old 03-30-2011, 03:56 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
You can use chsh to change your default shell. To display your current shell, issue the following:
Code:
echo $SHELL
For a full list of shells on your system, do this:
Code:
chsh --list-shells
Using that, you can put the full path in your script and it will use that particular shell. Hope that helps,

Josh
 
Old 03-30-2011, 04:02 PM   #3
expert_vision
LQ Newbie
 
Registered: Mar 2011
Posts: 13

Original Poster
Rep: Reputation: 0
Thx for quick reply. Apparently my linux doesn't have chsh:
-sh: chsh: not found
Actually it's a firmware with embedded linux for wl500g asus router(http://code.google.com/p/wl500g/).
 
Old 03-30-2011, 04:18 PM   #4
expert_vision
LQ Newbie
 
Registered: Mar 2011
Posts: 13

Original Poster
Rep: Reputation: 0
I ended up using bc - a command line calculator .. but I would still would like to know how to run a script with a different shell .. for future scripts.
 
Old 03-30-2011, 04:33 PM   #5
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
To run a normal script with a different shell interpreter, all you need to do is change the first line of your script, as such:
Code:
#!/bin/bash
to:
Code:
#!/bin/zsh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Where does the shell script run by default? timdvtemp Linux - Software 3 03-03-2011 08:49 AM
in bash shell how to run shell script during startup rammohan04 Red Hat 2 07-31-2009 02:07 AM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
Restrict a Shell Script to run from a shell bharaniks Linux - Security 7 08-26-2007 10:57 PM
I made a shortcut to a shell script and it is using default shell icon... shlinux Linux - Software 2 04-20-2006 06:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration