LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-16-2013, 12:41 PM   #1
mpc8250
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
multiple shell scripts in multiple environments - quick question


Hi All

We have to ssh as root into a remote host, which runs a csh environment.
We need to invoke, from local host using ssh, a Bourne shell script a.sh on the remote host to set our application environment.
This script a.sh then calls other Bourne shell script b.sh to actually execute our desired commands.

ssh --> a.sh (in csh environment) --> b.sh (in csh environment)

We are having getting b.sh to execute. ssh simply stops at end of a.sh

We tried chaining the commands like
su auser -c "./a.sh; ./b.sh" (still it won't work)

Would the experts share their workaround ?

Thank you very much
Sincerely
 
Old 01-16-2013, 01:20 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
In order to run a script that's written in bash (i.e. it's interpretter is #!/bin/bash), in any other shell, use either sh or bash before script name, as:-
Code:
~$ sh scriptname
OR
~$ bash scriptname
In your case, try:-
Code:
~$ su auser -c "sh a.sh; sh b.sh"
OR
~$ su auser -c "bash a.sh; bash b.sh"
Simple use of ./ will certainlly give your error.
 
Old 01-16-2013, 05:13 PM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Normally you would put "#!/bin/sh" at the beginning of the file and make it executable.

Then the file itself identifies the shell to be used for interpreting the file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] Multiple Desktop Environments Arch Linux jdh313 Linux - Newbie 5 08-11-2011 11:27 AM
SHELL SCRIPT for multiple SCRIPTS rahulruns Programming 5 11-25-2009 12:13 PM
handling multiple files in shell scripts. wilsonsamm Linux - General 7 07-05-2006 07:36 PM
Using multiple desktop environments under Slackware? Frank Slackware 6 08-06-2003 03:38 AM
Compiling KDE 3.0 w/ multiple architecture flags (quick and easy question)? MatMan5959 Linux - Software 4 05-31-2002 02:57 PM


All times are GMT -5. The time now is 06:42 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration