Php script that copies Unix folders?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Php script that copies Unix folders?
# 1  
Old 09-26-2006
Php script that copies Unix folders?

I work as a website designer where I work on different directories on a server but my boss doesnt give me root permission for security reasons. So I have a temporary folder where I work and he copies the files over as he has root permission. The command he uses is usually like:

cp -fR /home/johndoe/public_html/websites/teachered/* /home/teachered/public_html/

And that updates the websites.

Is there a way a PHP script can be made where I just click it like a regular URL and it updates the Unix folders? A password field would also be nice, so the copy is made only if the password is correct.

thank you
Edtech
# 2  
Old 09-26-2006
I searched the net and it looks something like the following is possible ?

<?
exec("cp -r /var/www/mysite /var/backup");
?>

It looks like I'd need to make different files for different folders. They would be lying in the root folder so the permissions would be there.

My next step is creating a password field. How do I pass the password from a textbox to the php environment? Then it would be something like:

<?
if ($password == "ThePassWord100") {
exec("cp -r /var/www/mysite /var/backup");
}
?>

Am I on the right track?
thanks!
# 3  
Old 09-26-2006
If you need root permissions to copy them, it's not going to work. The web server probably has less access than you do.

You could ask your sysadmin to put you in a group with write-access to that folder, so you can copy yourslef...
# 4  
Old 09-26-2006
He probably doesnt want to give me write-access, although I'll mention this to him.
So it wont copy even if the PHP file was copied in the root folder? The sysadmin would copy the file there and then I would call it from there in the browser. Wont work?

There's a php Copy command too, how about that?
thanks!
# 5  
Old 09-26-2006
Quote:
Originally Posted by edtech
There's a php Copy command too, how about that?
thanks!
The effects of PHP copy and shell copy are just the same. Normally, the copy is effected with the user that is associated with the Web server, and at the end whether you can copy or not depends on the permissions and/or owner/group of the directories/files concerned.

But normally, the document root (e.g. /var/www) is created with root-only write privilege, so this is unlikely to work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and delete files and folders which are n days older from one unix server to another unix server

Hi All, Let me know how can i find and delete files from one unix server to another unix server which are 'N' days older. Please note that I need to delete files on remote unix server.So, probably i will need to use sftp, but question is how can i identify files and folders which are 'N'... (2 Replies)
Discussion started by: sachinkl
2 Replies

2. UNIX for Dummies Questions & Answers

finding files in unix and excluding certain folders

hi good day I am using redhat linux. Is there a better utility than the 'find' command to search for files I am trying to search through and enitre directory such as /repos for a files that have 'UAP' in it. However there are some '.step' folders littered throughout the /repos folder at varying... (8 Replies)
Discussion started by: johnstrong
8 Replies

3. Shell Programming and Scripting

I need a korn shell script that renames and copies

I have 68 servers whose /etc/ntp.conf file have the wrong NTP server name and they need to be updated with a different or correct NTP server name. I am doing this on AIX Here is what I would like. and I would need a script that would rename the old /etc/ntp.conf and add a date stamp to it ... (1 Reply)
Discussion started by: jesifra
1 Replies

4. Shell Programming and Scripting

Recursive Replication of Unix folders to Windows

Requirements: ftp files recursively from unix to windows. Replicate directory paths on unix (source) to windows (destination) and place files in their respective folders. There are no set number of files per directory nor fix number of dirA or dirB etc.... Source OS: Solaris... (5 Replies)
Discussion started by: mlv_99
5 Replies

5. Homework & Coursework Questions

Script that copies one file to/over another

1. The problem statement, all variables and given/known data: Write a script that asks for 4 arguments, and the 1st and 3rd need to be -i and -o, and the 2nd/4th need to be file names. Technically, it's supposed to be run as: ./Lab_14.sh -i input.txt -o output.txt Depending on how many... (0 Replies)
Discussion started by: SoVi3t
0 Replies

6. UNIX for Dummies Questions & Answers

Delete folders and files in it - UNIX

I need to delete a folder and files in it of yesterdays and simply put this in cron. Folder name - "2010-03-2010" File name - "eprod_06_23.dmp" and "eprod_06_23.exp" Actually this folder and file is been created by a script which takes a backup of DB everyday.Thats why it creates folder and file... (3 Replies)
Discussion started by: j_panky
3 Replies

7. Windows & DOS: Issues & Discussions

Copy folders and subfolders from unix to windows

Sir From a unix machine some folders and their folders have to be copied to windows XP PC. Please help me with a batch file or a shell script. I am new to the the shell and batch files. Thanks in anticipation. sastry (3 Replies)
Discussion started by: chssastry
3 Replies

8. Shell Programming and Scripting

Script to print multiple copies of the same file

Hi, this is my first post so I hope I have placed it in the appropriate section! I have created a looping script to print a text file multiple times. The script works great, and it displays the job numbers of all the prints that result from its execution. The trouble is, only the first job... (1 Reply)
Discussion started by: Alpha7
1 Replies

9. Filesystems, Disks and Memory

Sun UNIX Files & Folders listing

Hi guys, i'm new to UNIX and only know a small amout about it, but have just had some changes at work which now require me to interact with and work on SUN Unix systems often. I have reasonable knowledge of PC's but hope that you will be able to help me with these questions. Part1. I would like... (3 Replies)
Discussion started by: Scrat
3 Replies

10. Shell Programming and Scripting

how to syncronize two folders in unix

how to syncronize two folders in unix the requirement is---> only source folder changes should be replicated to destination. destination does not change and need not replicate to the source. (1 Reply)
Discussion started by: sushil_d10
1 Replies
Login or Register to Ask a Question