|
|
Subject:
How do I do a su -c "command" so that bash comes out as the default shell.
Category: Computers > Operating Systems Asked by: cheekoo1-ga List Price: $10.00 |
Posted:
22 Jan 2004 13:32 PST
Expires: 21 Feb 2004 13:32 PST Question ID: 299071 |
please answer only with regards to total description. I need to "su" to a given user name whose default shell is "tcsh", but use a "bash" shell to execute a few shell scripts/commands which are written in "bash" and not in "tcsh".(Due to paucity of time and lack of experience I cannot convert them into "tcsh" from "bash".) I cannot use su -c <username> -s <shell name> option, because my version of solaris does not allow me the "-s" option. In effect I am trying to call something like this : $build_cmd = ("su amazon -c \"bash -c \"cd $AMAZON/buildfwrk/bin; source boo t.sh; ant usage\"\" > " ."`/opt/admin/bin/newlogf $HOME/_build.$build_area/build_logs` 2>&1"); system ($build_cmd); But given the number of double quotes I have to use, I am not sure whether the above given command will really work.Please give me the code, if you are suggesting that I write a shell script to do the same. |
|
Subject:
Re: How do I do a su -c "command" so that bash comes out as the default shell.
Answered By: haversian-ga on 22 Jan 2004 22:03 PST |
Good evening cheekoo1-ga, If solaris prevents you from specifying a shell using -s, perhaps you can use bash to solve your problem. What I mean is that bash accepts arguments, one of them being a file to use in lieu of standard input. So, your command could read su amazon -c "bash /home/jrandomuser/commands.txt" This way, the one command that su allows you to run is bash. So far, so good. Next you need to get bash to run commands. You simply put them in a file, one command per line, exactly as you would type them at the commandline, and save that file somewhere accessible by user amazon. Then, have bash execute that file, and you're good to go. For you, this means putting cd $AMAZON/buildfwrk/bin; source boo [... - your lines got truncated oddly] in a file somewhere (say /home/jrandomuser/commands.txt) readable by user amazon. In fact, since you're no longer limited to one line, you can separate your commands more legibly with returns than ;s. Then execute the su command I gave above. When bash finishes with the file, it encounters the EOF, which causes it to terminate. This drops you back to tcsh, but (on my Linux system) does not end your su session. Solaris may behave differently. If you need this tested, I do have access to Solaris machines (Sol/Sparc, not Solx86) at university. -Haversian |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |