Forum Moderators: coopster & phranque

Message Too Old, No Replies

Script to move files on the same server

Without TAR

         

Mauricio

5:29 pm on Aug 27, 2004 (gmt 0)



I'm loking for a script wich moves directory/*.* to directory/*.* on the same server without do compression (my server does not support TAR).

I've find some ones wich does this but all of the requieres previous compression. I can't modify them because my skills in programing are less than zero absolute.

Thanks in advance.

Bluepixel

7:01 pm on Aug 29, 2004 (gmt 0)

10+ Year Member



Hi,

"cp -r /source /destination" if it's a *nix server. If you don't have shell access, you can execute it with perl through your webserver:
#!/usr/bin/perl
print "Content-Type: text/html;
print qx ("cp -r /source /destination");

Mauricio

8:11 pm on Aug 29, 2004 (gmt 0)



First at all, tank you!

When I saw the script I felt myself a little bit stupid just for ignore how to do something so easy (...and call myself an "adavanced user" Go figure).

Second: please, detail a little bit more how should I write /source and /destination because the script I done (backup.pl) just gives a 500 error message.
a) absolute path to the script: /home/httpd/vhosts/mysite.com/cgi-bin/backup/backup.pl
b) source: /home/httpd/vhosts/mysite.com/httpdocs/docs
c) destination: /home/httpd/vhosts/mysite.com/httpdocs/backup

And, yes, it's a linux server with Red Hat and a Plesk control pannel (server for dummies, like me)

Thanks in advance.

Mauricio

9:52 am on Aug 30, 2004 (gmt 0)



Exactly, the error I got is:

sh: cp -r
/home/httpd/vhosts/mysite.com/web_users/top/*.*
/home/httpd/vhosts/mysite.com/httpdocs/backup/*.*: No such file or directory
[Mon Aug 30 10:03:16 2004] [error] [client 80.58.13.43] Premature end of script headers: /home/httpd/vhosts/mysite.com/cgi-bin/backup/backup.pl

tombola

12:01 pm on Aug 30, 2004 (gmt 0)

10+ Year Member



No need to use the wildcards (*.*) to copy an entire directory, so:

cp -r /home/httpd/vhosts/mysite.com/web_users/top
/home/httpd/vhosts/mysite.com/httpdocs/backup

Mauricio

4:45 pm on Aug 30, 2004 (gmt 0)



I don't know what to do.

THIS doesn't works:

#!/usr/bin/perl
print "Content-Type: text/html";
print qx ("cp cartoon.htm joke.htm");

From the error log:

sh: cp cartoon.htm joke.htm: command not found
[Mon Aug 30 18:28:33 2004] [error] [client 80.58.13.43] Premature end of script headers: /home/httpd/vhosts/mysite.com/cgi-bin/backup/backup.pl

tombola

7:29 pm on Aug 30, 2004 (gmt 0)

10+ Year Member



To perform a system call, you have several options:

system("cp cartoon.htm joke.htm");

or:

$command = `cp cartoon.htm joke.htm`;

or:

$command = qx/cp cartoon.htm joke.htm/;

Note: you must use quotation marks for the first command, backquotes for the second and forward slashes for the third command...

Mauricio

12:06 pm on Aug 31, 2004 (gmt 0)



Thanks.

Now it works fine. I found another script (crone.cgi, a fake crontab) to do the copy automatically.

Thanks a lot again.

P.S.: a 55$ handbook helped me a lot too "Perl, CGI and Javascript complete")

VectorJ

4:56 pm on Sep 1, 2004 (gmt 0)

10+ Year Member



Just as an addendum, I think the problem is that you didn't put the full path to the cp command in your system call. "/bin/cp source dest" should work though.