View Single Post
  #1032  
Old 13.12.2019, 13:30
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Rabelux View Post
You mean something like
Code:
callSync("scp", sourceFile, "user@hostname:/path", "; echo $?")
or rather get the echo in a new call like callsync("echo $?")?
The question is what does callSync() return? The first, the last, or the sum of all echos to stdout?

What would be the benefit of using callAsync()? I thought using sync is better as i want to make sure the whole file has been copied.
callSync() will output stdOut or stdErr. You have to use the echo $? as the second command (using &), which will result in stdOut or stdErr + echo result. It is also possible to get just the exit code by redirecting redirect the stdOut & stdErr to null device.

callAsync() will be more suitable as the exitCode, stdOut or stdErr will be available to the callback function. This will be available after the external command has ended (in this case the file has been copied or failed). You then have to just query those properties before executing your code.

Feel free to find me in JD Chat if you need any help with this.
Reply With Quote