Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all, I am trying to build a script that runs on AIX, Solaris, and various flavors of Linux as well. It is very simple, or so I thought. I have the AIX and Solaris servers working well. Next I tried to get my workstation to run the script and it bombed. I am running Fedora 12 x86_64, but that isn't really important. I have various flavors of Linux. Some CentOS, RH, and even a Gentoo server. The script I have runs every hour on all servers. I can push out changes and install software with it, but the Linux WS won't run it. Here is my script:
uname=`uname`
os1="AIX"
os2="SunOS"
os3="Linux"
#echo $oslevel
if [[ $uname = $os1 ]] then
/tools/HourlyProcess/HourlyProcess_Kickoff_AIX
fi
if [[ $uname = $os2 ]] then
/tools/HourlyProcess/HourlyProcess_Kickoff_Sun
fi
if [[ $uname = $os3 ]] then
/tools/HourlyProcess/HourlyProcess_Kickoff_Linux
fi
exit
And here are the errors:
/tools/HourlyProcess/HourlyProcess_Kickoff: line 6: syntax error near unexpected token `then'
/tools/HourlyProcess/HourlyProcess_Kickoff: line 6: `if [[ $uname = $os1 ]] then'
Is this just an issue with going between ksh and bash?
Thanks, in troubleshooting the Solaris portion I had to remove the #!/bin/ksh at the top of the script. I doing all of that I also removed the ; before the then as well. It is working everywhere now, I didn't even notice that was gone until you brought it up.
Last edited by snakernetb; 02-16-2010 at 01:32 PM.
Reason: spelling
You can get the real ksh on Linux these days, so I'd specify that at the top again (check the paths on each OS).
You don't want to assume that the 'default' shell will always be ksh (or whatever).
You may not be able to know whether ksh is in /bin, /usr/bin or /usr/local/bin. For ksh scripts to run on all *nixes, they usually start:
#!/usr/bin/env ksh
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.