Q: Different results for the same command between popen and libssh When I run this command with popen, no worries.
I get a first information line and file contents.
if [ -f /dir/file.txt ]; then echo $(if [ -w /dir/file.txt ]; then echo 'ok'; else echo 'nok';fi) $(stat -c '%A  %W %Y %s' /dir/file.txt);if [ $(stat -c%s /dir/file.txt) -gt 0 ]; then cat /dir/file.txt;fi;else echo 'false';fi

When I run the same command via libssh I recovers only the first line.
With the "file size" field > 0.
Have you any idea why?

A: Big mistake on my part.
It must run one command at a time.  
In my case, only one echo like this:
if [ -f /dir/file.txt ];then echo -e \"$(if [ -w /dir/file.txt ];then echo 'ok';else echo 'nok';fi) $(stat -c '%A  %W %Y %s' /dir/file.txt) \\n $(if [ $(stat -c%s /dir/file.txt) -gt 0 ];then cat /dir/file.txt;fi;)\";else echo 'false';fi

Not echo and stat commands.
