in reply to Re: untaring at remote location
in thread untaring at remote location

Have you considered launching your program on the remote end and having it detach from its SSH session? Most likely a double-fork or simply launching it via nohup should put your script in the background, detached from the session that started it.

Also, the "Perl" script you've shown is basically just a shell script. If you really want to use Perl, I would replace cd by the chdir function and the invocation of utpsm_lts_server.pl to either the do function or just start that program directly from the calling SSH script.

Also note that exec never returns.

Replies are listed 'Best First'.
Re^3: untaring at remote location
by t-rex (Scribe) on Jun 16, 2016 at 06:58 UTC

    thanks for the info , i dont know how to use nohup , perl is also new for me hence i wasnt aware of the chdir and do , now i was trying to use fork: sabkuch.pl forks a child which will run this server , the code is something like this, but that too is not getting me desired result

    1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 system('tar -xvf test.tar'); 7 8 my $child_pid = fork; 9 10 if (!defined $child_pid){ 11 print "couldn't fork \n"; 12 } 13 14 else { 15 print "in child , now executing \n"; 16 exec('cd utpsm_run_automation && perl utpsm_lts_server.pl') 17 or die "can't run server.pl in sabkuch child \n"; 18 } 19 20 exit;

    could you please help me with this ?

      I think the child will also need to ignore the HUP signal:

      $SIG{SIGHUP} = 'ignore';

      But personally, I would instead look at the nohup manpage and just use that.

      Also, your error description doesn't really help me help you with your problem as you don't tell us what exactly happens.

        the error is basically my host script hangs up....coz the server when started (on remote by sabkuch.pl) doesn't end as it is a while (1) keep listening to port my point is can u help me with have a parent process which forks out a child and exits. now this child will keep running ( server.pl) till the machine is on or something weird happens. I hope i can make myself clear