ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
in solaris, a default shell script runs with /bin/sh
on linux a /bin/sh shell is actually /bin/bash
and very annoyingly is not as compatible as it says it is.
So a linux /bin/sh is not actually a valid /bin/sh
script on another system (solaris at least).
in Solaris I would advise that you use /bin/ksh which will run most bash scripts.
IMHO korn is a much better scripting shell anyhow.
Last edited by bigearsbilly; 12-04-2007 at 02:55 AM.
Hi...
Thanks acid_kewpie and ghostdog74
In my target system the default is configured to be ksh.
But Im using Bash to execute the script.(#!/usr/bin/bash)
The script was fine in Redhat.
Should I be replacing $(cmds) to `(cmds)` to make it work in Solaris?
Hi...
Thanks acid_kewpie and ghostdog74
In my target system the default is configured to be ksh.
But Im using Bash to execute the script.(#!/usr/bin/bash)
The script was fine in Redhat.
Should I be replacing $(cmds) to `(cmds)` to make it work in Solaris?
Why it doesn work in Solaris?
Thanks.
you can try (for the $() syntax ). Later version of Solaris comes with bash.
Code:
# bash myscript.sh
or if you have defined the shebang as #!/usr/bin/bash
then just
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
The $(command) works under Solaris with most shells including:
/usr/xpg4/bin/sh (POSIX compliant shell)
/bin/ksh (ksh88)
/usr/dt/bin/dtksh (old CDE ksh93 with X11 support)
/bin/ksh93 (the latest ksh)
/bin/bash
/bin/zsh
It doesn't works with /bin/sh which is not POSIX compliant but kept here for upward compatibility requirements (POSIX shell can break legacy /bin/sh scripts).
As bigearsbilly suggests, the preferred shell under Solaris is ksh (and ksh93 when available).
I also strongly advise deciding/finding out which shell you ought to use in prod eg ksh and using the same for dev.
In the same spirit, always use an explicit shell invocation eg
#!/bin/ksh
It's amazing how often the default shell in any given env is NOT the same as yours....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.