473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Can anyone tell me why this doesnt work please


Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>

or perhaps try it on your system and tell me if it does/doesnt and what
your linux is?

I've also tried

<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

-nigel-
Sep 6 '06 #1
13 1571
ni*****@by.uk wrote:
Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>

or perhaps try it on your system and tell me if it does/doesnt and what
your linux is?

I've also tried

<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

-nigel-
What kind of error do you get?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 6 '06 #2
In article <BN******************************@comcast.com>,
js*******@attglobal.net says...
ni*****@by.uk wrote:
Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>

or perhaps try it on your system and tell me if it does/doesnt and what
your linux is?

I've also tried

<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

-nigel-

What kind of error do you get?

--
Hi Jerry - $returnval contains '2' in each case.
$arrayout never seems to contain anything.

I can however do -
tar --help
which does return the help.

I've also tried to archive a single file with the same result
ie. tar -cf myfile.tar foo
returns an error of 2

and i've tried the --ignore-failed-read flag to no avail.

-nigel-
Sep 6 '06 #3
ni*****@by.uk wrote:
In article <BN******************************@comcast.com>,
js*******@attglobal.net says...
>>ni*****@by.uk wrote:
>>>Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>

or perhaps try it on your system and tell me if it does/doesnt and what
your linux is?

I've also tried

<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

-nigel-

What kind of error do you get?

--


Hi Jerry - $returnval contains '2' in each case.
$arrayout never seems to contain anything.

I can however do -
tar --help
which does return the help.

I've also tried to archive a single file with the same result
ie. tar -cf myfile.tar foo
returns an error of 2

and i've tried the --ignore-failed-read flag to no avail.

-nigel-
Nigel,

Does the cron job user have write access to the directory where you're
writing myfile.tar? And does it have read access to /home?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 6 '06 #4
On Wed, 06 Sep 2006 16:37:35 GMT, ni*****@by.uk wrote:
>In article <BN******************************@comcast.com>,
js*******@attglobal.net says...
>ni*****@by.uk wrote:
Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>
<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

What kind of error do you get?

Hi Jerry - $returnval contains '2' in each case.
$arrayout never seems to contain anything.

I can however do -
tar --help
which does return the help.

I've also tried to archive a single file with the same result
ie. tar -cf myfile.tar foo
returns an error of 2

and i've tried the --ignore-failed-read flag to no avail.
errno 2 is "No such file or directory" - so I'm not quite sure what to make of
that; permission denied would seem more likely.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 6 '06 #5

ni*****@by.uk wrote:
Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>

or perhaps try it on your system and tell me if it does/doesnt and what
your linux is?

I've also tried

<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

-nigel-
Append this:

for ($i = 0; $i < count($arrayout); $i++) {
echo $arrayout[$i] . "\n";

}

and see what the command output is.

Chris

Sep 6 '06 #6
In article <11**********************@i42g2000cwa.googlegroups .com>,
mr********@gmail.com says...
>
ni*****@by.uk wrote:
Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>

or perhaps try it on your system and tell me if it does/doesnt and what
your linux is?

I've also tried

<?php
exec("/bin/tar -c * \| gzip \myfile.tgz",$arrayout,$returnval);
?>

Both work fine from the command line neither work at all from PHP

-nigel-

Append this:

for ($i = 0; $i < count($arrayout); $i++) {
echo $arrayout[$i] . "\n";

}

and see what the command output is.

Chris

Thanks Chris but I already have this which is how I know the array is
empty. I'm getting more confused by the minute.

-nigel-
Sep 6 '06 #7
In article <NJ******************************@comcast.com>,
js*******@attglobal.net says...
>
Nigel,

Does the cron job user have write access to the directory where you're
writing myfile.tar? And does it have read access to /home?

Hi Jerry

Sadly I'm not a Linux expert - I know what persmissions are but I dont
know what a "cron job" is.
I'm guessing you mean the apache server?

/home is the directory the php file is in as well as the test file to be
archived and is set to 777 for directory and all files - I panicked when
I first couldnt make it work! I assume that means it has full read/write.

I have so far assumed all permissions are granted as the machine is my
test machine not networked to anything and I have everything I can find
set to 777 to avoid this ... I seem to remember running chmod 777 from
the root and recursing... I then manually change back my final test
files/dirs to 755 and so on... ie the reverse procedure used on a public
system.

I also log on as root. (I have tried another user account and that
performs the same).

I can see where you are going and you may well be right - I just dont
know what to look for ... how can I identify the less obvious things I
need to check for permissions? (I can do file & directories its perhaps
that cron job etc.)

-nigel-

Sep 6 '06 #8
In article <03********************************@4ax.com>, an**@andyh.co.uk
says
Hi Jerry - $returnval contains '2' in each case.
$arrayout never seems to contain anything.

I can however do -
tar --help
which does return the help.

I've also tried to archive a single file with the same result
ie. tar -cf myfile.tar foo
returns an error of 2

and i've tried the --ignore-failed-read flag to no avail.

errno 2 is "No such file or directory" - so I'm not quite sure what to make of
that; permission denied would seem more likely.
Thanks for the info Andy.
Can you tell me where that is documented - I can't find it.

I don't get this - the same error 2 occurs even if I use * or *.* or just
a directory name. The tar manual suggests those are all valid so I dont
know how it can think the file isnt there... stwange .....vewy stwange...

This is bound to be a permissions thing somehow ... you're both right I
expect... I just can't find the blockage.

-nigel-
Sep 6 '06 #9
<ni*****@by.ukwrote in
news:MP************************@news-text.blueyonder.co.uk...
>
Using linux

<?php
exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval);
?>
Try to use singe quote instead the double quote. I'm no sure if this is the
same in PHP as is in Perl but in Perl double quote evaluate something but
single quote don't.
Example in Perl:

$name = "nigel";
print "Hallo $name";
>Hallo nigel
$name = "nigel";
print 'Hallo $name';
>Hallo $name
Maybe is some similar in PHP.

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Sep 7 '06 #10
In article <ed**********@ns.felk.cvut.cz>, st****@practisoft.cz says...
<
Try to use singe quote instead the double quote. I'm no sure if this is the
same in PHP as is in Perl but in Perl double quote evaluate something but
single quote don't.
Example in Perl:

$name = "nigel";
print "Hallo $name";
Hallo nigel

$name = "nigel";
print 'Hallo $name';
Hallo $name

Maybe is some similar in PHP.

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Thanks Petr - yes the quotes are different in PHP too... doubles allow
more escaped characters.

Turns out that wasn't it though - see my next post !

-nigel-
Sep 7 '06 #11

damn and blast ... colour me stupid and spank my soft extremeties...

It was those last explanations that set me thinking...
It had to be permissions because it works ok on the command line so...
I ran my chmod -R / again... (not recommended on a live system folks!)

It turns out the directory the .tar file is created in must have 777
permissions ... 775 wont do it... it must have that extra bit set.

(I dont understand why at all - I can exec other apps that write to files
without any trouble at all... I REALLY would like an explanation if
anyone has one, bearing that fact in mind)

It generates a file not found because it's looking for the tar file and
hasn't created it (possibly error reporting could be tightened up to be
more accurate in Tar) ...

Anyways -- many thanks to all who followed me on my wild goose chase.
All I have to do now is see if I can make it work on the live system...

Oh boy oh boy.... aint pc's fun. I can even go to bed tonight.

-nigel-

Sep 7 '06 #12
<ni*****@by.ukwrote in
news:MP************************@news-text.blueyonder.co.uk...
>
It turns out the directory the .tar file is created in must have 777
permissions ... 775 wont do it... it must have that extra bit set.
I'm not a Linux guru but maybe can help you to use some tar parameter. Try
to tell to tar thaht the temporary file must be created in /tmp dir. This
directory used to have 777 privileges at all. Or try to create tar file in
/tmp directory and after creating copy tar file to desired destination.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Sep 7 '06 #13
In article <ed***********@ns.felk.cvut.cz>, st****@practisoft.cz says...
<ni*****@by.ukwrote in
news:MP************************@news-text.blueyonder.co.uk...

It turns out the directory the .tar file is created in must have 777
permissions ... 775 wont do it... it must have that extra bit set.
I'm not a Linux guru but maybe can help you to use some tar parameter. Try
to tell to tar thaht the temporary file must be created in /tmp dir. This
directory used to have 777 privileges at all. Or try to create tar file in
/tmp directory and after creating copy tar file to desired destination.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Thanks Petr thats pretty much what I did.
Its still a puzzle I need to understand but at least I can get it working
now. I just hope I dont run into problems using chmod with PHP
through apache or that will screw me up.

-nigel-
Sep 8 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
6
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: ...
2
by: Tony | last post by:
I found similar code for encoding/decoding strings in VB which works fine. However I wanted to use it in a C# projected and can't get it to work. When it executes the TransformFinalBlock() call at...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
0
by: Mike | last post by:
Hi All, I am using a COM object and so I have to use a form for it to work. The problem is I need to run it as a service as well. When I run it in a test scenario everything works fine and...
4
by: Bruno Alexandre | last post by:
Hi guys, I'm using the asp:menu component and everything worked great in my machine, but when I upload the files to our Hosting I got this: http://portal.filterqueen.dk/portal2.fq/test.aspx ...
1
Digital Don
by: Digital Don | last post by:
I am writing a program for Peg solitaire... To check for no repetition of previous states I use a Set for storage of Board states.. The pronblem is when I declare the set as type char i.e. set...
1
by: Dany13 | last post by:
hi all. i using some text box for input value and some localvarible for passing this data to dataset . give instance for correct row of dataset and data in data table . use one gird view for...
3
by: Tahir | last post by:
Hi, i am delevoping an ASP.NET website which worked well on my old web host and now working on localhost but now it doesnt works on my new host. i have new registered and ftp the files that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.