Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How do I run a background command via Net::SSH::W32Perl

by boat73 (Scribe)
on Nov 14, 2005 at 15:29 UTC ( #508331=perlquestion: print w/replies, xml ) Need Help??

boat73 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings wise ones. I am trying to set my display to a windows machine and then kick off a command and run it in the background on a solaris 8 machine. The code works fine as far as setting the display and starting the xterm goes but, drops the ball on putting the process in the background. Has anyone run into this problem and or found a solution? As always any help is greatly appreciated. Below is a simple example of what I am trying to do. The script fist starts exceed in passive mode to allow my display to be set.
use Net::SSH::W32Perl; $host = "$ARGV[0]"; $user = "$ARGV[1]"; $pwd = "$ARGV[2]"; $cmd = 'setenv DISPLAY 10.1.42.151:0.0; xterm &'; &startexceed; print "EXCEED STARTED\n"; my $ssh = new Net::SSH::W32Perl($host, protocol => '2', debug => + 1); $ssh->login($user, $pwd); my ($out, $err, $exit) = $ssh->cmd($cmd); print "OUT => $out\n\n"; print "ERR => $err\n\n"; print "EXIT => $exit\n\n"; sub startexceed{ $exceed = "C:\\Program Files\\Hummingbird\\Connectivity\\9.00\\Exc +eed\\exceed.exe"; use Win32::Process; $Result = Win32::Process::Create($ProcessObj, "$exceed", "$exceed -m passive", 0, NORMAL_PRIORITY_CLASS, ".")|| die "\nCould not create exceed\.exe\n"; $ProcessObj->Wait(10); $ProcessObj->GetExitCode($exitcode); unless($exitcode == "259"){ die "exceed exited with a return code of $exitcode\n"; } }

Replies are listed 'Best First'.
Re: How do I run a background command via Net::SSH::W32Perl
by samizdat (Vicar) on Nov 14, 2005 at 17:17 UTC
    I have not tried to do anything from a Doze box, but take a look at Re: run X-application via system call? for some pointers, in particular the -c option to xterm -e bash. Either the --rcfile or -c option will be right for what you want to do.
      Thanks for the ideas guys but none work so far. I did see a posting from someone that I needed to close STDERR/STDOUT/STDIN prior to running the script in order to run procs in the background. Could anyone tell me how to do that? (Not a Unix guy)
        Unfortuantely, the only doze box I have is on a DHCP connection and will not accept raw IP settings.

        Some things to check: setenv is a c-shell command. If your unix box is running sh or bash, use
        DISPLAY=xyz.xyz.xyz.xyz:0:0; xterm -c 'myprog.pl &'
        or something like that.
Re: How do I run a background command via Net::SSH::W32Perl
by JamesNC (Chaplain) on Nov 14, 2005 at 16:13 UTC
    There are 2 ways I know of:
    #backticks using start<br> my $rv = `start exceed.exe`; #system using the 1 option system( 1, "exceed.exe" );
    JamesNC
      Perhaps I am not following your response. This looks like a solution toward starting the exceed process on my win32 system. What I am looking for is a method of running a command in the background on the remote Unix system via Net::SSH::W32Perl.
        Hi boat73,

        Perhaps man nohup would be worth reading.

        Hope this helps.

        Martin
        sorry about that... perhaps you need to escape the \& ??

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://508331]
Approved by sweetblood
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2021-05-17 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (162 votes). Check out past polls.

    Notices?