Usage of system command with tar in source code

Dear All.

I would like to use a legacy command of tar through system call in C source code.
With legato Develope studio system. I made some sample code as below in order to compress for some directory

{
RunSystemCommand(“cd /home”);
RunSystemCommand(“tar -czvf log.tar.gz /home/log”);
}

After executing code. I got the result log message as below
but there is no log.tar.gz file in /home directory

Jan 6 02:04:11 | svclayerlogctl[21792]/svclayerLogCtlComponent T=mLogFileMgr | svclayerLogCtlComponent.c RunSystemCommand() 69 | Success: cd /home
Jan 6 02:04:11 | svclayerlogctl[21792] | | tar:
Jan 6 02:04:11 | svclayerlogctl[21792] | | Removing leading ‘/’ from member names
Jan 6 02:04:11 | svclayerlogctl[21792] | |
Jan 6 02:04:11 | svclayerlogctl[21792] | | a home/log
Jan 6 02:04:11 | svclayerlogctl[21792] | |
Jan 6 02:04:11 | svclayerlogctl[21792] | | a home/log/logfile0.txt
Jan 6 02:04:11 | svclayerlogctl[21792] | |
Jan 6 02:04:11 | svclayerlogctl[21792] | | a home/log/logfile1.txt
Jan 6 02:04:11 | svclayerlogctl[21792] | |
Jan 6 02:04:11 | svclayerlogctl[21792]/svclayerLogCtlComponent T=mLogFileMgr | svclayerLogCtlComponent.c RunSystemCommand() 69 | Success: tar -czvf log.tar.gz /home/log

Do I miss something ?

Thank you all

I don’t see problem on WP77 FW 9.1 with following code in legato app:
system(“tar -xvf /tmp/test.tar.gz -C /tmp”);

Do you try to set the app to unsandboxed?

Dear
The command of tar -xvf which you recommand works well, but The command of tar -czvf is not.
Definitely I did unsandboxed the app.

Currently I use WP85/WP75 R16.1 version

Thanks

it is working on my side:
system(“tar -czvf /tmp/test2.tar.gz /tmp/LICENSE.txt”);

Thanks jyijyi
I miss the directory path…
After add directory path…It works.

I should have to use command as below with adding directory path
“tar -czvf /home/log.tar.gz /home/log”

Thank you again.