Is it possible to ssh to a server in perl and execute multiple commands without doing them all at once?
I know I can potentially do something like
However, I'd like the functionality where I don't have to keep SSHing over and over to the same machine. Further, I'm not sure how to catch output from each command that's executed. If anyone could point me in the right direction or share some sample code with me, I'd appreciate it.
Looks good. Thanks for the info. However, I'm not the admin on the server where I do my work is it possible store the pm file locally and perl recognize it? Sorry, but I'm pretty new to perl.
Looks good. Thanks for the info. However, I'm not the admin on the server where I do my work is it possible store the pm file locally and perl recognize it? Sorry, but I'm pretty new to perl.
Installation of Perl modules requires lot more work than just dumping pm files into a directory.
Thankfully, complete Perl installations provide the CPAN module that takes care of:
- connecting to the CPAN module repository to fetch the latest module version
- resolving all dependencies, and installing required modules (for example, DBD::Oracle module requires DBI module; so CPAN will install DBI before DBD::Oracle)
- running tests added by the module author
- installing manual pages that come with the module
and so on...
So the first thing you may want to check is if you can use the CPAN module. The Perl script "cpan" is the command-line interface to the CPAN module; so see if these commands work on your *nix box -
("cpanp" or CPANPLUS is a more intuitive and user-friendly alternative to CPAN.)
It is recommended to run these commands as root, failing which your SysAdmin would've (or should've) given you access.
In order to install Perl modules in your local directory, set the PERL5LIB environment variable so that it points to your directory of choice.
If you cannot use cpan, then you are on a path that even seasoned Perl programmers fear to tread.
Hello guys,
You are my last hope. I googled for hours and tried so many things but I can't find a way to fix my problem.
So there we go:
I open a SSH tunnel to my linux vps.
My client sends every 5-minutes a keepalive package and I also set the "ClientAliveInterval" value to 300 in the... (8 Replies)
Hi ,
I am running a script on multiple servers.When I run that script on one server,I want to exit from that server and want to go to next server.PFB script:
Suppose there are 3 servers:server1,server2,server3.I am currently in server1.
for h in {2..3}
do
ssh username@server$h <<EOF
... (4 Replies)
I ran a job using SSH and then used screen command followed by space bar. Then I ran the job. But after some hours, the internet connection was lost.This had happened to me before. I used to run the whole job again. Today I came across the fact that I could restart the jobs without having to do it... (2 Replies)
Hi,
I want to execute some script on the remote session and transfer the processed file on remote machine to local machine.
I tried with ssh-keygen and ssh-copy-id but seems that this has been disable on the remote machines,
Is there any possiblity that I can save the remote username and... (7 Replies)
Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Hello,
When I connect to a HP-UX 11.23 and/or 11.31 after a time without activity, the session hang.
There is not TMOUT stablished, and the session NOT finish, always keep hang after about 20min of inactivity period.
Anyone knows if this problem is related to HP-UX or network... (1 Reply)
I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands.
With the putty I can connect to the device and execute the commands without any issues.
Here is the sample script
my $ssh =... (0 Replies)
Hey,
I'm trying to build customized behavior in a bash script for when it is run within an ssh session. This is how I'm finding out if the current session is ssh:
USER=`whoami` ... (3 Replies)
We have a Solaris 10 server that we're migrating an old Cadre Teamwork application to. We find that when users on Sun workstations use ssh -X <username>@<new server> and run Teamwork on this new server it is fine.
When cygwin users and linux users run ssh -X to get to this new platform they... (0 Replies)
I know the root login/password for a machines, and I want to automate some commands like this from each:
ssh root@remoteHost1 "tail /var/log/messages"
ssh root@remoteHost2 "tail /var/log/messages"
ssh root@remoteHost3 "tail /var/log/messages"
ssh root@remoteHost4 "tail /var/log/messages"
ssh... (2 Replies)