User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,365 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,025 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2143 | Replies: 35
Reply
Join Date: Dec 2007
Location: Bangalore,India
Posts: 118
Reputation: carobee is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
carobee carobee is offline Offline
Junior Poster

executing unix commands from php

  #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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: executing unix commands from php

  #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"); ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2007
Location: Ireland
Posts: 1,630
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Rep Power: 6
Solved Threads: 70
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

  #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  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: executing unix commands from php

  #4  
Feb 1st, 2008
Oh thanks.. Umm.. so the OP should use zxvf since he/she is creating a tar.gz file ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2007
Location: Ireland
Posts: 1,630
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Rep Power: 6
Solved Threads: 70
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

  #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  
Join Date: Dec 2007
Location: Bangalore,India
Posts: 118
Reputation: carobee is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
carobee carobee is offline Offline
Junior Poster

Re: executing unix commands from php

  #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  
Join Date: Jan 2007
Location: Ireland
Posts: 1,630
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Rep Power: 6
Solved Threads: 70
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

  #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  
Join Date: Dec 2007
Location: Bangalore,India
Posts: 118
Reputation: carobee is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
carobee carobee is offline Offline
Junior Poster

Re: executing unix commands from php

  #8  
Feb 3rd, 2008
have already done that without much success. also tried passthru() ...no much success
Reply With Quote  
Join Date: Jan 2007
Location: Ireland
Posts: 1,630
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Rep Power: 6
Solved Threads: 70
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: executing unix commands from php

  #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  
Join Date: Dec 2007
Location: Bangalore,India
Posts: 118
Reputation: carobee is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
carobee carobee is offline Offline
Junior Poster

Re: executing unix commands from php

  #10  
Feb 4th, 2008
Originally Posted by DimaYasny View Post
what OS is installed there?


Linux 2.4.18-3
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 12:18 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC