Visit Our UNIX and Linux User Community

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

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to use ssh to run shell script on a remote machine?
# 1  
Old 01-13-2012
how to use ssh to run shell script on a remote machine?

how to use ssh to run shell script on a remote machine?
ssh user@remote sh ./script.unx

i ran the above command

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 03:44 AM.. Reason: please use code tags for your code and data
# 2  
Old 01-13-2012
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...
# 3  
Old 01-14-2012
ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log &

the remore script is as below :
cdtm=`date +'%Y%m%d_%H%M%S'`
for inst in 13 14 15 16 17 18
`nohup DSM -dg 1 -i 85 -m DUPLICATE -c ${inst} -t 18 -a -DAILY > log 2>&1 &`

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

below is the error:
nohup: cannot run command `DSM': No such file or directory

Last edited by Scott; 01-14-2012 at 02:15 PM.. Reason: Code tags, please...
# 4  
Old 01-14-2012
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.
# 5  
Old 01-14-2012
Its seems more that DSM is not in PATH...
Give the path to DSM and try
# 6  
Old 01-14-2012
how to give PATH to DSM ..............
# 7  
Old 01-14-2012
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:


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 02:53 PM.. Reason: ...

Previous Thread | Next Thread
Test Your Knowledge in Computers #820
Difficulty: Easy
Before CSS, nearly all presentational attributes of HTML documents were contained within the HTML markup.
True or False?

10 More Discussions You Might Find Interesting

1. Ubuntu

Run a script at remote server without ssh password

Hello, What I want to do is to run a file on remote server by running a script at localhost but script should not ask ssh password of my remote server when script is executed. Scenario1: To copy files from server2 to data server:$ scp -r root@server2_ip:/var/www/html/*.* /var/ When I enter... (6 Replies)
Discussion started by: baris35
6 Replies

2. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./ file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of ... (2 Replies)
Discussion started by: manishtri88
2 Replies

3. Linux

Executing a script in remote machine through ssh

How to execute a script in remote machine through ssh I have a script which does some backup activity in remote machine. Wanted to keep backup also in remote machine. ssh -l username <remote machine> "commands to be exceuted as ; separted" but how to put the script in the place of... (5 Replies)
Discussion started by: sanvel
5 Replies

4. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to Server from my machine, my ip was Source Destination was UP, with IP This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

5. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < However, when I try to pass arguments to it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

6. UNIX for Advanced & Expert Users

Unable to run the script on remote machine Using Expect script

Not able to execute the file in remote host using except utility I am automating the SFTP keys setp process: So i created the expect script for controlling the output of shell below is my main code: Code: #!/usr/bin/expect set fd set password close $fd set df set app close $df... (1 Reply)
Discussion started by: Manoj Bajpai
1 Replies

7. Shell Programming and Scripting

shell script to run after ssh logout from another machine

Scenario: I currently manager a cluster at work which is on a private network and i constantly need to ssh to other clients for diags e.t.c. I created a debain client which i use as my gateway to get to all the clients on the private network and I then created a Shell menu script which will make... (4 Replies)
Discussion started by: defamer
4 Replies

8. Shell Programming and Scripting

How to run perl script in remote machine from java application?

Hi I am working in a java application. I need to execute a perl script(linux) which is in remote machine in java application from local machine(windows). I need to do this process automatically that is without manual intereption. Now I will explain the process clearly, at present to run the... (1 Reply)
Discussion started by: bassma
1 Replies

9. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

10. Shell Programming and Scripting

Issues using ssh from crontab to run remote script from

I have a solaris9 x86 server using ssh as follows: SSH Version Sun_SSH_1.0, protocol versions 1.5/2.0. The remote server solaris9 sparc has exactly the same version ssh installed. I am running a script on my server which includes the following command to run a script on the remote server:... (4 Replies)
Discussion started by: frustrated1
4 Replies

Featured Tech Videos