Run SCP in backgroung using Perl CGI


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run SCP in backgroung using Perl CGI
# 1  
Old 01-12-2012
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.
# 2  
Old 01-12-2012
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
# 3  
Old 01-12-2012
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 01-12-2012
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";
   }

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to run script through CGI?

Hi I have written a script and I want it to be run from web with the help of CGI. can you please guide me . below script is working fine if run from backend but not sure how I should run through web. #!/bin/bash string1=look string2=0 string3=.sdn.dnb echo -n "enter... (3 Replies)
Discussion started by: scriptor
3 Replies

2. Shell Programming and Scripting

scp Commands not executing via cgi script

Hi, I have a CGI script, which includes a python custom header file. The cgi script calls a few functions. Py file. #resourcemanager creation def make_rm(rmip,nip,nport): fp = open("temp1.txt",mode="w") fp.write('<?xml version="1.0"?>\n<!-- Licensed under the Apache... (2 Replies)
Discussion started by: adi.6194
2 Replies

3. Shell Programming and Scripting

CGI Perl : while loop in CGI perl

Hi Team, I am trying to connect to database(succeeded ) and print the records on the browser using while loop. But the elements of array are not displayed instead while loop is displayed directly. Instead of the below I can embed html statements in print but I am looking for the below style as I... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

5. Shell Programming and Scripting

Perl cgi pages out of cgi-bin folder in WINDOWS

Hi team, I have a typical problem with cgi pages in apache webserver in WINDOWS I am able to execute(display) the pages that are saved in cgi-bin folder. But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder. Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies

6. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

7. Shell Programming and Scripting

Run system command in perl cgi

Hi guys, got a problem with a perl cgi script over here. I need it to run a system command to get the status of a process. Unfortunately the process is owned by a specific user and only this user can get its status. So i tried running the command from the perl cgi with "su", but then i get the... (12 Replies)
Discussion started by: polki
12 Replies

8. Shell Programming and Scripting

how to run cgi -script on Cygwin ?

All, I would like to run a cgi script in cygwin which i have installed in WinXP. My CYGWIN directory structure is /var/www/ drwxrwx---+ 2 user Users 0 Nov 23 16:24 cgi-bin drwxrwx---+ 3 user Users 0 Oct 22 17:21 htdocs drwxrwx---+ 3 user Users 0 Oct 22 17:22 icons and another... (1 Reply)
Discussion started by: jambesh
1 Replies

9. UNIX for Dummies Questions & Answers

Run ksh script from cgi

Hi, I'm developing a system which requires me to run a ksh script from within a cgi script. What sort of syntax will I need to do this, I'm sure it's simple but can't find out how anywhere! Thanks. (2 Replies)
Discussion started by: hodges
2 Replies

10. Cybersecurity

Run CGI As User..?

Hi, My server is set up so that all cgi scripts are run as user nobody, instead of the user's username. Now I know you can use cgi-wrappers, but someone please give me detailed information, on how to make ALL scripts run on the server to by default, run as the user? And not to run as user... (1 Reply)
Discussion started by: jason6792
1 Replies
Login or Register to Ask a Question