Re: [Ssh-sftp-perl-users] Executing Command FIles (KSH) not Simply One-line Commands
Brought to you by:
dbrobins
From: Bryan B. <br...@bu...> - 2006-04-14 18:24:14
|
>> I'm running into a situation here where I need to connect to remote >> servers using this module and be able to execute kron shell file >> commands >> i.e. .ksh. The idea here is to be able to do it while these ksh files >> are >> residing locally where the perl code is run and not on the remote >> servers. >> This is to centralized the code all in one location. >> - Can this be done? >> - If not, can any one suggest workarounds or other solutions? >> - How do admins manage the code that needs to run on 100's of remote >> servers ? >> > > >>Its pretty simple, load the entire shell file into a scalar variable, and >>run that as a command over the channel. If you use return codes to check >>the result its even more trivial as Net::SSH2 and/or Net::SSH::Perl gives >>you the return code of the channel. > >>Hope that helps. > > >>Bryan >>http://sourceforge.net/projects/rover > > I think loading entire script in single variable is not a good idea. Its > difficult for debugging. You will not know where is it going wrong. > > -Gurunath > > I'm not sure I agree with that. You know where you go wrong because you have standard out and standard error streams to read from your Net::SSH object. You would trouble shoot it the same way if you ran the script from the box. When dealing with channels this isnt much different then loading the file to the box, running it, and reading your return code/stdout info. Except you dont have to load the file to the box, which is what your trying to do anyway. Good luck. Bryan http://sourceforge.net/projects/rover |