Perl SSH without a perl module


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl SSH without a perl module
# 1  
Old 08-20-2012
Perl SSH without a perl module

I'm trying to create a perl script that will do 1 SSH session, but be able to write multiple commands to the session and receive multiple outputs. I know there are modules out there like Net:SSH::Perl, but I'm not allowed to use it. I was thinking of doing something like an open3 on an ssh session. After that, I would potentially be able to send commands and receive output from stdout and stderr (maybe). I'm thinking there's a flaw here in my logic, but I can't think of what it is. Before sitting down and writing myself into a corner, have any of you done something like this before? Can anyone point of the flaw in my logic? I'm not sure if it'll work, but I'd be very frustrated if I were to code something that could never have worked.

Thanks in advance for any and all input.
# 2  
Old 08-20-2012
Do you have to use perl?

What OS(es) and shell?
# 3  
Old 08-20-2012
Quote:
Originally Posted by jim mcnamara
Do you have to use perl?

What OS(es) and shell?
Yep. We're using Solaris, which has become a pain in the butt. There are a few modules out there that come default with many Linux distros, but not for Solaris. We use ksh most times. I'm not really looking for some backtick solution that requires passing a long shell script. I'm determined to figure out a better way.
# 4  
Old 08-20-2012
What, precisely, are you trying to do? Remember that you can send entire shell scripts over ssh. Maybe there's a non-perl solution.
# 5  
Old 08-20-2012
cpan has thousands of modules.

You do not have to put them in a system directory, just deploy them in a user/application directory and add them to @INC. So, in that sense you can use whatever you want/need.

And generally, creating ssh sessions in shell is trivial. Otherwise in perl you call fork/exec to another module or perl subroutine to do your work. This is how you get around backticks. fork/exec creates a child process which you can manipluate by "owning" tty stdin/stdout in the parent perl module. If you want.

I think you might want to look at Stevens 'Advanced Programming in the UNIX Environment'. It is C, but Solaris perl has a complete interface to the calls mentioned there. Or. Google for 'Perl UNIX system programming'. Lots of system-level perl code for UNIX/Linux is avalable is out there.

Short answer: yes you can do what you want, pretty close to your description. You need to pick up more about UNIX system programming first.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl module

I am recieiving an out of memory issue in my perl module while updating the records in the oracle table. Let me know what are the check or troubleshoot steps need to be done from my end to fix the issue. (1 Reply)
Discussion started by: ramkumar15
1 Replies

2. Shell Programming and Scripting

Help for Perl module bundle.

I have a file of lot of perl modules in tar.gz format. They all have dependency on each other for installation. Can anybody guide me for making a bundle so that I can run it in one go and install all the modules. Please note that I can't use CPAN as we don't have Internet connectivity on our... (3 Replies)
Discussion started by: nixhead
3 Replies

3. Shell Programming and Scripting

calling perl subroutine from perl expect module

All, Is it possible to call a subroutine from the perl expect module after logging to a system that is within the same program. My situation is I need to run a logic inside a machine that I'm logging in using the expect module, the logic is also available in the same expect program. Thanks,... (5 Replies)
Discussion started by: arun_maffy
5 Replies

4. Shell Programming and Scripting

Which Perl Module to use?

Hi, I need to read an excel binary file and write the data to a text file. Is it possible using Spreadsheet-ParseExcel-0.58 ? If not, is there any module available in CPAN to do this? Thanks, Js (1 Reply)
Discussion started by: jisha
1 Replies

5. Shell Programming and Scripting

Perl Module

Hi, Please help me!! Im wondering if anyone can help me with a problem i have with some perl modules. My problem is: I'm trying to connect remote host to a unix box from a windows machine. So i'm developing an application to do this. I'm programming it in perl with tcl/tk Gui interface.... (13 Replies)
Discussion started by: Phi01
13 Replies

6. Shell Programming and Scripting

Help with Perl Module

I dont know if this is a dumb question, but I am unable to move ahead and need help - There is a perl module called Header.pm which was written by someone else. I am trying to write a simple perl script which uses a function provided by the module. The function has been exported by the module... (9 Replies)
Discussion started by: NewDeb
9 Replies

7. Shell Programming and Scripting

Perl Module Help

Hi All, I am using a perl module Win32::AdminMisc in my perl script. When i running in activestate perl v5.10.0 it shows folling error --- Can't locate loadable object for module Win32::AdminMisc in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at example.pl Please reply. ... (7 Replies)
Discussion started by: suprcool
7 Replies

8. Shell Programming and Scripting

Installing Perl Module

Hi All, When I tried to install Math::Pari module in a AIX 5.3 server,I am getting the following error. # pwd /usr/local/bin # cd Math-Pari-2.010709 # perl Makefile.PL Did not find GP/PARI build directory around. Do you want to me to fetch GP/PARI automatically? (If you do not, you... (2 Replies)
Discussion started by: surjithss
2 Replies

9. UNIX for Advanced & Expert Users

help with perl module installation

Hi, I am trying to install perl modules in HPUX under my account. I do not have the root permission. The module name I am trying to install is Spreadsheet-WriteExcel. I have downloaded the tar.gz file from CPAN and extracted the same under my home directory. When I try do 'perl... (2 Replies)
Discussion started by: sabyasm
2 Replies

10. Shell Programming and Scripting

Replace Perl Module name in all Perl scripts

I want to replace a Perl module name in all my Perl Scripts in the cgi-bin directory. How is it possible? I have the following statement in my scripts use myUtil; I want to change it to use myUtil777; Regards, Rahul (2 Replies)
Discussion started by: rahulrathod
2 Replies
Login or Register to Ask a Question