Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scp then ssh? other option? 1

Status
Not open for further replies.

dwcasey

MIS
Oct 31, 2002
179
US
I have a script I want to run on a many servers. It essentially is cleaning up some old files from an old application.

It's designed to run locally on the server itself. It has a few functions within...kill necessary processes associated with cleanup, check if filesystem exists, if so, remove it, check for entry in inittab, if exist, remove it, remove a few files associated with old application.

So I could just do a for $i in servers.lst do scp myscript then another for loop to ssh the script. But then all my logging will be on the server and not local.

Could I just encapsulate myscript.ksh in a startmyscript.ksh which will log everything local?

 
Experiment with
Code:
cat myscript | ssh -T user@myhost ksh  > mylog
Maybe someone can sort out the UUOC - I cant get
Code:
ssh -T user@myhost ksh < myscript
to work


On the internet no one knows you're a dog

Columb Healy
 
If you're happy with scping the script across first, then you should be able to log the output locally by running it like this:

Code:
ssh user@myhost /path/to/script > /tmp/local_log_file 2>&1

That is unless there are some explicit redirections to log files inside the script, which of course will be created on the system where it runs.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top