How do I do a su -c "command" so that bash comes out as the default shell.
-
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.
-
Answer:
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
cheekoo1-ga at Google Answers Visit the source
Related Q & A:
- In Visual Studio 2012 or 2013, how can I register a DLL file on Windows 7 64-bit computer using a Custom Action command?Best solution by Stack Overflow
- How do I reset a new default homepage?Best solution by SharePoint
- How do I make a Vitamin C standard solution?Best solution by answers.yahoo.com
- How do I set a personal picture as my default in Yahoo?Best solution by Yahoo! Answers
- How do i isolate a in p=a+b+c?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.