I have tried Karate framework feature karate.fork to execute SSH/SCP commands but sysOut is not capturing output values to validate. It returns only exitCode (0: represent script executed successfully, non-zero : represents the script error code).
I am facing 2 issues right now. It would be great if you guide me for below listed issues:-
Operating System : Windows 10
Code snippet - ISSUE-1
* def command =
"""
function(line) {
var proc = karate.fork({redirectErrorStream: false, useShell: true, line: line });
proc.waitSync();
karate.set('sysOut', proc.sysOut);
karate.set('sysErr', proc.sysErr);
karate.set('exitCode', proc.exitCode);
}
"""
* command('ssh user@<remote-server> "cd /data && ls"')
* match sysOut contains 'volume1'
* assert exitCode == 0
Karate Debug Logs shows
22:17:29.915 [1606236446563] DEBUG com.intuit.karate - inputrun1
22:17:29.916 [1606236446563] DEBUG com.intuit.karate - outputrun1
22:17:29.924 [1606236446563] DEBUG com.intuit.karate - volume1
22:17:29.954 [ForkJoinPool-1-worker-3] INFO com.intuit.karate - **sysOut undefined**
Also, facing another issue - ISSUE-2
* command('scp -r -i ~/.ssh/id_rsa user@<remote-server>:/data/volume1/ D:/karatetest/test/features/api/output')
20:07:59.947 [1606574279820-err] DEBUG com.intuit.karate - 'scp' is not recognized as an internal or external command,
20:07:59.947 [1606574279820-err] DEBUG com.intuit.karate - operable program or batch file.
The above SCP command is working fine in command prompt and in powershell window separately. But it throws 'scp' is not recognized as an internal or external command when I execute the same command in karate project inside VS code and when I ran karate command in VS code command prompt using java -Dkarate.config.dir
=test/resources/ -cp test/karate.jar com.intuit.karate.Main test/features/api/test_bash_script.feature. I have verified the environment variables path and physical path has scp application (C:\Windows\System32\OpenSSH). Earlier this was working for me and suddenly it throws this exception. I am not sure this issue appearing because of I have uninstalled application and installed new app eclipse for java.
Thanks Chandra