Results 1 to 5 of 5
I am trying to call gzip inside my c prog in Ubuntu with the system() function :
system( "gzip file.dds" );
But nothing happens!The file is present in the current ...
- 11-07-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 3
[SOLVED] system() and gzip
I am trying to call gzip inside my c prog in Ubuntu with the system() function :
system( "gzip file.dds" );
But nothing happens!The file is present in the current directory, and system() returns 0.
If I call system( "gzip -h" ) instead, it does print the help message as intended.
If I type the command by hand in the shell, it works.
Same problem with zip : system( "zip tmp.zip file.dds" );
Any idea somebody?
Thanks.
- 11-07-2008 #2
try something like:
system("gzip '/home/share/test/filename'");
hope this helps...Gerard4143
- 11-07-2008 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 3
Thanks for the answer Gerard, but still the same.
I also tried to chmod 777 everything.
It does not seem to be due to permissions.
- 11-07-2008 #4this is the code I used, both on Puppy Linux and Suse 11.0, and it worked with no problemsCode:
#include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { system("gzip 'filename'"); exit(EXIT_SUCCESS); }
- 11-08-2008 #5Just Joined!
- Join Date
- Nov 2008
- Posts
- 3
Ok, found my bug from your simplified code.
I was building a command string with sprintf(), but passing system( "command" ), instead of system( command ).
Isn't that great after a quarter century programming in C/C++ !
Thanks again for your help.


