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 :

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.

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

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

you can do it as

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