Gaurav
Gaurav

Reputation: 21

How to run ksh shell script on remote server

I have a ksh script 01.sh on server A and I need to run it on server B using ssh. I do not want to copy it on server B to run it. Also, there are 3 arguments which should be passed with this file execution.

I tried this but it does not work. $ssh serverB /usr/ga/ctm/scripts/01.sh $arg1 $arg2 $arg3 Error is: file 01.sh not found on server B

Please guide me how can I do this?

Upvotes: 0

Views: 3082

Answers (1)

AlastairG
AlastairG

Reputation: 4314

You can only execute a file on serverB if the executable file is on serverB's file system (or in it's memory somehow). There is no other way.

HOWEVER: If you have netfs you can reference the file on serverA from serverB. E.g. do:

ssh serverB /net/serverA/usr/ga/ctm/scripts/01.sh $arg1 $arg2 $arg3

You will need to ensure that netfs is set up correctly to allow serverB to read the file from serverA. Why don't you want to copy the file across? Use scp to do it.

Upvotes: 1

Related Questions