View Full Version : is it possible to untar?
The Linguist
9-9-04, 01:59 AM
Is it possible to untar a file on the server? It seems so much easier to upload one file then a whole whack of files (and faster) and then untar them?
Croc Hunter
9-9-04, 02:32 AM
Neville put it simply:
You need to create a little php file
Create a file in notepad (word wrap turned off) containing the following line:
<? system( "tar xzvf file*.tar.gz" ) ?>
Save this file as "setup.php"
Upload setup.php inside the htdocs directory.
Point your browser to your website such as http://www.yourdomain.com/setup.php
The Linguist
9-9-04, 02:36 AM
<? system( "tar xzvf file*.tar.gz" ) ?>
is this correct then
<? system( "tar moodle.tar.gz" ) ?>
or is the * necessary? that part is a little confusing.
Croc Hunter
9-9-04, 02:55 AM
I haven't tried it but imagine
<? system( "tar xzvf your-filename-here*.tar.gz" ) ?>
xvf may work in place of xzvf ( tar xzvf file.tar.gz, x = extract, z = use if there's gz extention, v = verbose, f = file ) the * is not necessary.. try with/without it.
The Linguist
9-9-04, 11:44 AM
I tried<? system( "tar xzvf moodle-latest-14.tar*.tar.gz" ) ?> but nothing happened? I also tried it without the .tar (before the *) and that didn't work either.
I set the file up as a subdomain using the folder outside of htdocs option and uploaded the tar and the setup.php file into the htdocs folder of the subdomain. I'm pretty sure that should have worked.
All I can say is I learn something new everytime I come to this forum. Thanks so much for your help.
RocketJeff
9-9-04, 02:11 PM
You might want to take a look at PHP Shell (http://www.gimpster.com/wiki/PhpShell) (or one of the alternatives listed on that page).
The advantage is that you won't have to keep modifying/uploading a script every time you want to run a FreeBSD command (like tar).
The disadvantage is that it is a big security hole if it isn't secured properly. Make sure you have it password protected. It also would be wise to change its name (so a hacker can't get lucky) and to not put a link to it on any of your pages.
The Linguist
9-9-04, 07:15 PM
I tried the code above, but it wasn't working for me, so I did a google search and found my answer on the devshed forums. this works perfectly<?
$ac=`/usr/bin/tar -xzf file-name.tgz`;
echo "OK";
?>
Croc Hunter
9-10-04, 08:51 AM
Good advice Jeff
Thanks for posting the solution Linguist. :)
danespen
9-19-04, 12:32 PM
Thank you Linguist :)
The Linguist
5-3-05, 07:46 PM
I would now like to be able to do the opposite. I want to be able to tar or zip my site and then download it as a backup. Is this possible?
I've got 5gb of space so, I may was well put it to use.
5GB is a little more than DVD-R.
Have you copied 5GB file on your machine?
Just copying may take long time.
If you try to compress lots of files into one huge archive, it will take very long time.
And PHP will time out and give 500 error.
Even Perl and shellscript may go over 20Sec CPU time limit.
So. it can be done, but in small batches.
How to use 'tar' command is explained many time, so you should be able to find it by searching.
The Linguist
5-3-05, 09:22 PM
I wasn't going to do it all at once. I realize that since I am using about 1gb of storage that I would time out. I figured I would back up a few key directories and download them to my home pc.
As for tarring a directory most of what I found is based on php shell which as I understand it has some security implications. I am more interested in something safer. Perhaps a script along the lines of the one for untar outlined above. that I can upload each time I use it.
David Byrnes
5-3-05, 10:04 PM
<?
$ac="/usr/bin/tar -xzf file-name.tgz";
echo "OK";
?>
I've been trying to get this to work all day, and it does absolutely nothing. I too am trying to install Moodle, and have the file moodle-1.4.4.tar on my space. I have a directory off the root called english, with an htdocs directory inside that. The
moodle-1.4.4.tar is in htdocs. I placed the code above in a file, called untar.php, changing file-name.tgz to moodle-1.4.4.tar, and then execute. It seems to do ok, but it runs very fast, echos the OK, but nothing happens. What am I doing wrong? I've also tried to install various php shells, including myshell, phpshell. and nothing is working for me today. :(
David Byrnes
5-3-05, 10:18 PM
Well, finally something seems to have worked. Unfortunately, not this script. Yesterday, I had uploaded the .zip file for Moodle, and used a different php script, found in this forum, to unzip it. But I had a problem, deleted the whole thing, then tried again. This morning, the same script I used yesterday did nothing. And continued to do nothing all day. Until 5 minutes ago. Now it works. VERY STRANGE.
Possibly, it was simply failing because of PHP time limit,
untill server load became sufficiently low to let it finish.
PHP often makes your life complicated with silly features.
The Linguist
5-4-05, 03:45 AM
You might want to take a look at PHP Shell (http://www.gimpster.com/wiki/PhpShell) (or one of the alternatives listed on that page).
I tried that but it doesn't work because powweb has safe mode on... is there another way?
The Linguist
5-4-05, 04:10 AM
I found a page with a list of shell scripts (http://www.club.cc.cmu.edu/~brian/info/cgi-shell.html) and I uploaded CGI-Telnet (http://www.rohitab.com/cgiscripts/cgitelnet.html). Any tips on where I would find the commands to make a tarbell of my directories?
I tried that but it doesn't work because powweb has safe mode on... is there another way?You know, the php.ini file is under your own control and you can turn safe mode off ?
Recommendation to do so: make a separate subdomain of the 'easy' type, password protect it, perhaps restrict access to the IP number of your computer, or if dynamic restrict to those of your ISP. Then place a copy of the php.ini into the subdomain htdocs folder and tweak it for the shell script to work.
I found a page with a list of shell scripts (http://www.club.cc.cmu.edu/~brian/info/cgi-shell.html) and I uploaded CGI-Telnet (http://www.rohitab.com/cgiscripts/cgitelnet.html). Any tips on where I would find the commands to make a tarbell of my directories?
http://www.freebsd.org/cgi/man.cgi?query=tar&apropos=0&sektion=0&manpath=FreeBSD+5.3-RELEASE+and+Ports&format=html
David Byrnes
5-4-05, 11:07 AM
Possibly, it was simply failing because of PHP time limit,
untill server load became sufficiently low to let it finish.
PHP often makes your life complicated with silly features.
That MAY have been the problem. But I'm not sure. I used an unzip script day before yesterday, and it worked fine. That was about noon. Yesterday, the script acted like it worked, but too quickly. Like, maybe 5 seconds of wait, then the status bar said Ready, but no list of files unzipped. Oh well, no biggie now. It worked finally.
Next time, use -v option when it's available.
Also, take a look at the error output with "2>&1 " or other means.
Then you may know what's going on.
<?
# -v option and stderr redirect applied to your example
echo `/usr/bin/tar -vxzf file-name.tgz * 2>&1`;
?>
David Byrnes
5-4-05, 01:49 PM
Next time, use -v option when it's available.
Also, take a look at the error output with "2>&1 " or other means.
Then you may know what's going on.
<?
# -v option and stderr redirect applied to your example
echo `/usr/bin/tar -vxzf file-name.tgz * 2>&1`;
?>
Okay, so what does the -v do?
user00265
5-4-05, 02:53 PM
Verbosity, prints out what it's doing.
As for me bing a Linux/Unix shell user, I use this:
tar -xzf filename.tar.gz
This works as well:
tar -xzf file.tgz
And this is for bzip2 tarballs files:
tar -xjf file.tar.bz2
The v switch is optional.
The Linguist
5-4-05, 04:57 PM
You know, the php.ini file is under your own control and you can turn safe mode off ?
I knew that, but obviously I had forgotten. d'uh. Thanks for the help.
patrickpawlowsk
5-6-05, 04:00 PM
I've use zip on windows and tar on linux but I have a zip file that I would like to upload and unzip on the PW server. Can I use tar for that?
I've use zip on windows and tar on linux but I have a zip file that I would like to upload and unzip on the PW server. Can I use tar for that?Disclaimer: "until someone else turns up with better information" -
I suggest you try to use GUNZIP/GZIP with the ref: http://www.freebsd.org/cgi/man.cgi?query=gzip&sektion=1&apropos=0&manpath=FreeBSD+5.3-RELEASE+and+Ports
patrickpawlowsk
5-6-05, 05:57 PM
<? system("unzip -o PHP-Nuke-7.5.zip") ?>
did the trick. I had to use the -o option to overwrite any existing files.
Thanks everyone.
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.