how to use ssh to run shell script on a remote machine? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

how to use ssh to run shell script on a remote machine?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-13-2012
only4satish only4satish is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 21 August 2014, 5:14 AM EDT
Posts: 62
Thanks: 27
Thanked 2 Times in 2 Posts
how to use ssh to run shell script on a remote machine?

how to use ssh to run shell script on a remote machine?

Code:
ssh user@remote sh ./script.unx

i ran the above command


./script.unx HAS NOHUP COMMAND IN ITS BODY, I AM GETTING ERROR AS NOHUP NOT FOUND...
i tried to run that script from remote server, its working fine


do ineed to set environment varaibles to remote server


please help ????

Last edited by vbe; 01-13-2012 at 02:44 AM.. Reason: please use code tags for your code and data
Sponsored Links
    #2  
Old 01-13-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 19 September 2014, 3:13 PM EDT
Location: Switzerland - GE
Posts: 5,738
Thanks: 157
Thanked 400 Times in 375 Posts
nohup is not in capital letters and what makes you think it is nohup the culprit?
show us the output displayed, maybe also the content of your script could help...
Sponsored Links
    #3  
Old 01-14-2012
only4satish only4satish is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 21 August 2014, 5:14 AM EDT
Posts: 62
Thanks: 27
Thanked 2 Times in 2 Posts

Code:
ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log &

the remore script is as below :

Code:
#!/usr/bin/ksh
cdtm=`date +'%Y%m%d_%H%M%S'`
hst_nam=`hostname`
 
for inst in 13 14 15 16 17 18
do
`nohup DSM -dg 1 -i 85 -m DUPLICATE -c ${inst} -t 18 -a -DAILY > log 2>&1 &`
done
fi


above is the script , when i logging from that server and executed that script,,,, script is doing well

below is the error:

Code:
nohup: cannot run command `DSM': No such file or directory


Last edited by Scott; 01-14-2012 at 01:15 PM.. Reason: Code tags, please...
    #4  
Old 01-14-2012
Peasant's Avatar
Peasant Peasant is offline
Registered User
 
Join Date: Mar 2011
Last Activity: 19 September 2014, 7:28 AM EDT
Posts: 652
Thanks: 17
Thanked 146 Times in 142 Posts
The enclosing of nohup .. in ` is not needed.
You don't need subshell for it.

Put full path to DSM program in your code and recheck.
Sponsored Links
    #5  
Old 01-14-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 19 September 2014, 3:13 PM EDT
Location: Switzerland - GE
Posts: 5,738
Thanks: 157
Thanked 400 Times in 375 Posts
Its seems more that DSM is not in PATH...
Give the path to DSM and try
Sponsored Links
    #6  
Old 01-14-2012
only4satish only4satish is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 21 August 2014, 5:14 AM EDT
Posts: 62
Thanks: 27
Thanked 2 Times in 2 Posts
how to give PATH to DSM ..............
Sponsored Links
    #7  
Old 01-14-2012
curleb curleb is offline Forum Advisor  
Registered User
 
Join Date: Mar 2008
Last Activity: 23 September 2013, 4:29 PM EDT
Location: Surrounded...
Posts: 383
Thanks: 1
Thanked 28 Times in 27 Posts
Add the following to your own dot file so it's sourced upon login or be sure to define it ahead of use within your script:


Code:
PATH=${PATH}:"/path/to/DSM"

Otherwise, as had Peasant said: just be sure to provide the absolute path to DSM (ie, /path/to/DSM...). Both Peasant and VBE are correct, only VBE's correct on a more session-wide/global level on the remote machine.

To be clear, you'd need to define it on the remote machine in either case (script variable or $PATH), as that's where you're executing the call.

Last edited by curleb; 01-14-2012 at 01:53 PM.. Reason: ...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running remote system shell script and c binary file from windows machine using java ram.sj Shell Programming and Scripting 1 09-29-2011 06:58 AM
How to transfer files from unix machine to local machine using shell script? vidhyaS Shell Programming and Scripting 1 08-08-2011 10:27 AM
shell script to copy files frm a linux machine to a windows machine using SCP nithin6034 Shell Programming and Scripting 3 07-21-2011 12:56 AM
executing command in a remote machine through ssh - shell script rateeshkumar Shell Programming and Scripting 1 03-22-2011 03:33 AM
Setting environment variable on a remote solaris machine using shell script eamani_sun Shell Programming and Scripting 1 05-30-2008 10:05 PM



All times are GMT -4. The time now is 03:53 PM.