Executing remotely the script

Hi All,

I have a script to be executed in another machine. I connect to that machine from another server as a root ( this is the only configured access, as i cannot log in as a normal user). After that I have to switch to a normal user and that I can be able to executge that script. But all this is done manually, that why Im interested in finding a way to automate the execution and not typing always:

remsh machine_name
su - sc
./script.sh

Please could anyone help me

remsh machine_name "su - sc -c \"./script.sh\""

Thanks for your reply
I tried what you wrote but it didnt succeed. Here is the output

vasstat1:/tmp/vms1# remsh smsc1 "su - sc -c \"./kot\""
ttytype: couldn't open /dev/tty for reading
You have mail.
stty: : Unknown error
Not a terminal
stty: : Unknown error
stty: : Unknown error
su: ./kot: not found.

Does the script "kot" run as a cron job or does it request input?

The last error can be solved easy:
su: ./kot: not found.

remsh smsc1 "su - sc -c \"<full path to location of kot>/kot\""

It is OK now, I run it successfully. Just one more question. How can I transmitt one or two parameter with the script

E.g remsh smsc1 "su - sc -c \"./kot.sh 2007-01 06845444\""

Is it correct like this?

Looks fine to me

Hi again,

The output of the script above is supposed to be returned to the calling place.
I use rcp like below

rcp -p /var/opt/nokia/smsc/logdata/billfiles/out 172.20.1.25:/opt/output/daily_stats/config

I cannot understand why sometimes works and sometimes no, like today. It gives me this error
remshd: Login incorrect

Any clue?

rcp is remote copy. I think you could be getting this for 2 reasons.

A. Either you have 2 different login id's on these 2 machines.

B. The password for login id you are using on the server that you are executing the script has changed.

Let me know if you need more help.

THank you for your reply

I think none of two aletrnatives is the cause of this. Because yesterday it worked and the errror occured just today. No password changed.

Hmm ok one more thing to check out in that case

Verify if your .rhosts file in the remote server is configured properly i.e. to allow root access from your local host.

Check $HOME/.rhosts file

It should have permissioning as follows:

<machine name where remsh is getting executed> root

After checking above entries in .rhosts you can check the trust between the servers using..

#rlogin <servername> -l root

If you are able to logged in without prompting for password then you are done !!!

If the password is prompted then, remsh command also wont work.

Also if you have root access one thing might be that the passwords for root differ between the two machines.

Just spitting out different guesses here.

Hopefully this helps

Let me know

What about rsh ?? Can't i run a command/script in remote machine useing rsh ?

Examle-
rsh REOTE_MACHINE_NAME -n "chmod 664 SOME_FILE"

rsh or remsh is the same thing. Regardless of what you use if your remote host file (.rhost) files are not correct you won't be able connect between two different hosts.

I cannot undersand why remsh works properly and rcp (for turning back the value) doesnt work. I think the configuration for both this commands is the same, if it works for remsh should work for the other one too.