Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory monitor motherboard music netgear network printer problem ram registry router server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Linux VPS and Unzipping

Reply  
Thread Tools
ROYW1000's Avatar
Junior Member with 4 posts.
 
Join Date: Jan 2006
Experience: Intermediate
30-Apr-2006, 05:24 AM #1
Linux VPS and Unzipping
Hi

I have a Linux VPS server using Plesk COntrol Panel and I am having issues getting a script to unzip the files in a given location.

I believe this is due to the fact that the system security stops this from happening and it should only be run from the command line or terminal.

Has anyone else come across this as I have a program i wrote to obtain the files which is a php script and then i want to run another script to find all zip files in the given directory and unzip them.

Please let me know if you can help.


Thanks


Roy
linuxphile's Avatar
Administrator with 429 posts.
 
Join Date: Mar 2003
Location: MD
Experience: Intermediate
02-May-2006, 11:44 PM #2
What are the exact problems/errors you are receiving when you try to unzip? What command and options are you using?
ROYW1000's Avatar
Junior Member with 4 posts.
 
Join Date: Jan 2006
Experience: Intermediate
03-May-2006, 03:37 PM #3
Hi

I am trying to run a php script to obtain files and then unzip them. The program will not run as the files are in the root and I dont have permission from within the VPS. I do however have access to the php.ini in the root and the .conf files as all the sites running on the VPS belong to us.

We are trying to run the Wget and Gzip etc. I enclose part of the code. The issue i think can be solved from the php.ini or the .conf file but not sure what to edit to allow.
<?php
// destination directory for downloaded files - must be writable by PHP
$targetDir = "../feeds";
// path to wget program for retrieval
$wgetProgram = "/usr/bin/wget";
// path to various unzip programs
$unzipPrograms["zip"] = "/usr/bin/unzip";
$unzipPrograms["rar"] = "/usr/bin/unrar";
$unzipPrograms["gzip"] = "/usr/bin/gzip";
// check that target directory is writable, bail otherwise
if (!is_writable($targetDir))
{
print "<p>target directory ($targetDir) not writable - exiting</p>";
exit();
}
// check that wget binary exists, bail otherwise
/*
if (!file_exists($wgetProgram))
{
print "<p>wget program ($wgetProgram) not found - using PHP method</p>";
$usePHP = true;
}
*/
$usePHP = true;
// check for and disable any unzip methods that do not exist
foreach($unzipPrograms as $name => $program)
{
if (!file_exists($program))
{
print '<p>unzip program for '.$name.' ('.$program.') not found - disabled</p>';
unset($unzipPrograms[$name]);
}
}
function fetch_url($url,$filename)
{
$source = fopen($url,"r");
$destination = fopen($filename,"w");
if (!$source || !$destination) return;
while(!feof($source))
{
fwrite($destination,fread($source,2048));
}
fclose($source);
fclose($destination);
}
function unzip_zip($header,$filename)
{
global $unzipPrograms;
// check if zip format
if ($header <> "PK".chr(0x03).chr(0x04)) return false;
$command = $unzipPrograms["zip"]." -p ".$filename." > ".$filename.".unzipped";
exec($command);
unlink($filename);
rename($filename.".unzipped",$filename);
return true;
}
function unzip_rar($header,$filename)
{
global $unzipPrograms;
// check if rar format
if ($header <> "Rar!") return false;
$command = $unzipPrograms["rar"]." p -inul ".$filename." > ".$filename.".unrarred";
exec($command);
unlink($filename);
rename($filename.".unrarred",$filename);
return true;


Thanks

Roy
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:42 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.