Hi,
I am new to this FORUM and I hope to count with your precious support. I am trying to, after querying data from a DB, create on the fly "a tar file on my server". Is it possible?
My site is located on a Linux server.
I looked around the web for a solution but the possibilities found became frustrating.
Thank you for your attention.
LuyzNascimento
Compress Query to Tar
Moderator: General Moderators
-
luyznascimento
- Forum Newbie
- Posts: 10
- Joined: Wed Apr 04, 2007 9:46 am
feyd wrote:Unless my memory is failing, you would simply write the data to a file then call tar via system(), exec() or shell_exec().
Hummmmmmmmmmmmm...nice try. I will do it now and see what happens! I will try not to explode anything with this
Kind Regards,
Luyz Nascimento.
-
luyznascimento
- Forum Newbie
- Posts: 10
- Joined: Wed Apr 04, 2007 9:46 am
luyznascimento wrote:feyd wrote:Unless my memory is failing, you would simply write the data to a file then call tar via system(), exec() or shell_exec().
Hummmmmmmmmmmmm...nice try. I will do it now and see what happens! I will try not to explode anything with this)))
Kind Regards,
Luyz Nascimento.
No it does not work. I tried so many different things since then but I just round and round...now where to go?
Far from now I tried to learn shell programming. I became with the following:
Code: Select all
#!/bin/sh
#
if test -z $1
then
echo "empty directory - please inform one..."
else
cd "$1/"
tar -cf "$1.tar" cbq*
#ls -al
fiCode: Select all
shell_exec ('. cd.sh DirName');Any suggestions?
Luyz Nascimento
-
luyznascimento
- Forum Newbie
- Posts: 10
- Joined: Wed Apr 04, 2007 9:46 am
THE ANSWER OR WAY OUT AS U PREFER...
luyznascimento wrote:luyznascimento wrote:feyd wrote:Unless my memory is failing, you would simply write the data to a file then call tar via system(), exec() or shell_exec().
Guys and Girls,
After a long time searching, seeking, willing this information, this morning here in my bedroom, I woke up with something strange living in my ideas...so I got this happening:
1 - I seeked if PHP would have a function to CHANGE DIRECTORY - YES IT HAS: CHDIR("DIRECTORY_NAME"). With this I changed the way things acts - I was trying to execute the "CD" command line from linux into SHELL_EXEC - won t work as expected to. = WRONG WAY !!!
2 - With the new code on my hands I needed to develop a simple condition to discover if UNDERSTANDS the change directory situation and WORKED!!!
3 - the rest was only success and I DIVIDE IT WITH YOU BELOW, BECAUSE IT WAS NOT A WASTED OF TIME ANYWAY - AS WE CAN SEE - I LEARNED AND TRY TO SAVE YOUR TIME EITHER, TEACHING YOU? Well its up to you, I guess.
Code: Select all
The "$dir" variable - comes dynamically on my code, ok?
if (chdir("$dir/")){
shell_exec ('tar -cf '.$dir.'.tar cbq*');
}Kind Regards,
Luyz Nascimento