Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Run SCP in backgroung using Perl CGI

Shell Programming and Scripting


Tags
cgi; perl, perl cgi

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-12-2012
Navrattan Bansa Navrattan Bansa is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 10 April 2012, 5:26 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Run SCP in backgroung using Perl CGI

Hi
I am Run Perl CGI Script. In which i am running SCP Command. But I want that command to be run into background and exit the script. But Still Web page waiting for Finish the script.
I m doing like :

Code:
system ("scp -r machinename:/path/to/file/for/copy/ /path/for/ destination/directory/  &");

But it is not working fine. Still it is waiting for Finish the script.
Please help me out.
Sponsored Links
    #2  
Old Unix and Linux 01-12-2012
apatil65 apatil65 is offline
Banned
 
Join Date: Nov 2011
Last Activity: 14 September 2012, 4:46 AM EDT
Location: IN Chennai-INDIA
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Running SCP in BG

Please follow these steps and i will be using SCP in the example

1) SSH into server
2) Execute the SCP command to transfer files on remote machine
For example to copy the folder named “data” i would be

scp -r data root@machine2.com:/home

It will ask you for root password of machine2.com, After authentication the process should start

3) Stop the process by using ctrl + z

4) Now run the bg command
root@localhost [~]# bg

bg will start the previous SCP process you killed in background

5) Confirm if the process is running by using jobs command
root@localhost [~]# jobs

If everything is ok kill the terminal with “exit” command and fetch a cup of cofee.

Cheers,

Arun
Sponsored Links
    #3  
Old Unix and Linux 01-12-2012
Navrattan Bansa Navrattan Bansa is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 10 April 2012, 5:26 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Thank 4 Reply
But You misunderstood the Question.
I want to do via Perl CGI.
Manually i know how to do but how to do via Perl CGI
    #4  
Old Unix and Linux 01-12-2012
itkamaraj's Unix or Linux Image
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 25 June 2015, 3:24 AM EDT
Posts: 3,060
Thanks: 34
Thanked 661 Times in 640 Posts
you can do it as


Code:
 
open DATA, "<scp comamnd>|"   or die "Couldn't execute program: $!";
while ( defined( my $line = <DATA> )  ) {
     chomp($line);
     print "$line\n";
   }

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl newbie_01 Shell Programming and Scripting 3 11-06-2011 01:26 AM
Hidden Characters in Regular Expression Matching Perl - Perl Newbie kittyluva2 Shell Programming and Scripting 4 07-28-2011 01:31 AM
Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time. butterfly20 Shell Programming and Scripting 2 01-13-2011 07:35 AM
Passing date formats in Perl: i.e. Jul/10/2007 -> 20070710 (yyyymmdd) - Perl akil Shell Programming and Scripting 7 07-17-2009 09:09 AM
How to get PID of a backgroung prsc from that process??? alex_5161 Shell Programming and Scripting 9 06-04-2009 04:09 PM



All times are GMT -4. The time now is 06:15 AM.