executing unix commands from php

Reply

Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

executing unix commands from php

 
0
  #1
Feb 1st, 2008
hi,

i am runnning a php script where i try to decompress a file and the untar it.
the file in suppose x.tar.gz. so in my php script i call system command

system("gunzip /home/trial/x.tar.gz");
now to untar i use

system("tar xvf /home/trial/x.tar");

now the error creeps in. i am able to decompress the file i.e in /home/trial/x.tar is formed but when i try to untar it the result in shown in the webpage(running the php script) instead of untaring it in the /home/trial folder).

can anyone help?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: executing unix commands from php

 
0
  #2
Feb 1st, 2008
umm.. I am not sure about this. But shouldn't system("tar xvf /home/trial/x.tar"); be
system("tar xvf /home/trial/x.tar.gz"); ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 1,765
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Solved Threads: 85
Moderator
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

 
0
  #3
Feb 1st, 2008
xvf is for .tar only.
zxvf is for .tar.gz
Real stupidity always beats Artificial Intelligence. (Terry Pratchett)

BA BizMg, MCSE, DCSE, Linux+, Network+
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: executing unix commands from php

 
0
  #4
Feb 1st, 2008
Oh thanks.. Umm.. so the OP should use zxvf since he/she is creating a tar.gz file ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 1,765
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Solved Threads: 85
Moderator
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

 
1
  #5
Feb 1st, 2008
creating is czvf for .tar.gz

xzvf - Xtract,Zip,Verbose,File
czvf - Create,Zip,Verbose,File

just man tar
Real stupidity always beats Artificial Intelligence. (Terry Pratchett)

BA BizMg, MCSE, DCSE, Linux+, Network+
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

Re: executing unix commands from php

 
0
  #6
Feb 1st, 2008
i had done

system("tar zxvf /home/trial/x.tar.gz")
but without much success. if i put this option, it even doesnot produce x.tar file
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 1,765
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Solved Threads: 85
Moderator
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

 
0
  #7
Feb 1st, 2008
try the exec() function
Real stupidity always beats Artificial Intelligence. (Terry Pratchett)

BA BizMg, MCSE, DCSE, Linux+, Network+
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

Re: executing unix commands from php

 
0
  #8
Feb 4th, 2008
have already done that without much success. also tried passthru() ...no much success
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 1,765
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Solved Threads: 85
Moderator
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

 
0
  #9
Feb 4th, 2008
what OS is installed there?
Real stupidity always beats Artificial Intelligence. (Terry Pratchett)

BA BizMg, MCSE, DCSE, Linux+, Network+
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

Re: executing unix commands from php

 
0
  #10
Feb 4th, 2008
Originally Posted by DimaYasny View Post
what OS is installed there?
Linux 2.4.18-3
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC