executing script command on remote host

executing script command on remote host

Post by Dieter Plas » Fri, 04 Jun 2004 00:01:50



I want to run the following script as a cronjob.

ssh -l user remotehost
cd /logs/`TZ=GMT+24 date +20%y%m%d`
sh /home/user/script

Testing the script, each line as a single terminal input works fine.
Running all three lines in a script, the process gets stuck and doesn't
change into the log-directory.
I suspect it is obvious to the expert that this is not working. However
with my limited knowledge I haven't found a way out yet.

Thanks for looking into the matter!

Dieter

 
 
 

executing script command on remote host

Post by Brian Goug » Fri, 04 Jun 2004 00:24:02



> I want to run the following script as a cronjob.

> ssh -l user remotehost
> cd /logs/`TZ=GMT+24 date +20%y%m%d`
> sh /home/user/script

> Testing the script, each line as a single terminal input works fine.
> Running all three lines in a script, the process gets stuck and doesn't
> change into the log-directory.

Put the lines that you want to execute into a script on the remote
host and then do,

  ssh -l user remotehost remotescript

--
Brian Gough

Network Theory Ltd,
Publishing the GNU Bash Reference Manual --- http://www.network-theory.co.uk/

 
 
 

executing script command on remote host

Post by Bill Marcu » Fri, 04 Jun 2004 01:26:03


On Wed, 02 Jun 2004 17:01:50 +0200, Dieter Plass

> I want to run the following script as a cronjob.

> ssh -l user remotehost
> cd /logs/`TZ=GMT+24 date +20%y%m%d`
> sh /home/user/script

> Testing the script, each line as a single terminal input works fine.
> Running all three lines in a script, the process gets stuck and doesn't
> change into the log-directory.
> I suspect it is obvious to the expert that this is not working. However
> with my limited knowledge I haven't found a way out yet.

> Thanks for looking into the matter!

ssh -l user remotehost <<END
  cd /logs/`TZ=GMT+24 date +%Y%m%d`
  sh /home/user/script
END

When you use ssh in a script, without specifying a command, it takes
commands from standard input.

--
May 25  International Towel Day, in honour of Douglas N. Adams

 
 
 

executing script command on remote host

Post by Dieter Plas » Fri, 04 Jun 2004 20:46:00


Thanks a lot. Your remarks helped. The cronjob is running & I can sleep a
little longer in the morning .....
Ciao
Dieter
 
 
 

1. Need help for executing commands on remote hosts

        Hi, all.  I need some help in the area of remote command execution.
What I want is for a user to be able to enter a command while logged-in to
a host, and the command is actually a program on some other host somewhere.
The command is interactive, so stdin and stdout need to be connected to the
user's terminal.  I have looked at rsh, but it does not allow interactive
programs.  rlogin may be the answer, but I am hoping for something a little
more tansparent to the user.  Don't hesitate to throw some C code at me :-).

Any help will be greatly appreciated.  Email or post.

---
John Gordon


2. Changing active soundcard through kde (rh 7.3)

3. Clarifying problem to login to remote host and execute script

4. Does Linux support the LS-120 floppy drive?

5. Script to telnet to remote units and execute commands

6. Mandrake 7.1 Installing Diamond MX300 on Abit BE6-2 Mobo - No sound

7. remote telnet & execute commands via script (how to do it?)

8. Trident9660

9. unable to execute script using remote shell command

10. Executing commands on a remote m/c from a script

11. Script to detect user that is executing and execute commands accordingly

12. Script with commands destined for a remote host

13. executing script commands after su command