View Single Post
  #1029  
Old 11.12.2019, 19:25
Rabelux Rabelux is offline
Ultra Loader
 
Join Date: Oct 2018
Posts: 47
Question Exitcode of callsync()

Hi mgpai,
is there a way to retrieve the exit code of a callsync()-function?
Or to specify my question: how do I check whether the called function/script did not encounter any errors? If I got this correct a callsync() returns the first stdout that occours. In my case that doesn't leave a clue whether the call was succesfull.
To give you an idea what I'm trying to accomplish:
I have a headless setup of JDownloader on a remote server and after finishing a download I want that file to be copied to my local server via scp. If that was successfull the remote server should delete the file.
I got the copy-part working but cannot check whether it was successful.
My code:
Code:
//trigger: download stopped
disablePermissionChecks();
if (link.isFinished()) {
    var sourceFile = link.getDownloadPath();
    var result = callSync("scp", sourceFile, "user@hostname:/path");
    if (result == 0) {
        deleteFile(sourceFile, false);
        log(sourceFile + " should be deleted")
    } else {
        log("Err: scp-result = " + result);
    }
    if (package.isFinished()) package.remove();
}
Thanks in advance,
rabelux
Reply With Quote