CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
How can I pass an open session of Net::SSH2 to a script running in a forked subprocess?

 



dgalron
New User

Oct 18, 2012, 8:38 AM

Post #1 of 2 (1919 views)
How can I pass an open session of Net::SSH2 to a script running in a forked subprocess? Can't Post

I have a test script, which opens a session using Net::SSH2. After new,connect,auth...,channel,blocking(0) and shell the script reads and writes. Now I need to fork and run another script in the child process. This script should continue the dialog using already established session. The problem is: I have no idea how to pass this open session to the new script.
Thanks in advance.


rovf
Veteran

Oct 24, 2012, 1:42 AM

Post #2 of 2 (1885 views)
Re: [dgalron] How can I pass an open session of Net::SSH2 to a script running in a forked subprocess? [In reply to] Can't Post

How do you invoke the "new" script?

I have never tried it, but my attempt would be, to execute the new script in the context of the current one, i.e. after the fork(), when you are in the child process, execute the script with require or do. The (global) data of the parent script should then be available in the child.

I must admit that I don't know enough about Net::SSH2 to say for sure that this will work. In particular, I don't know what to do with the Net::SSH2 object you have allocated in the parent script. You certainly should not touch it (and, in particular, make sure that it does not get destructed).

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives