I want to run this script inside my Jenkins job. My goal is to save the cat output into a variable so that I can use it somewhere else.
#!/bin/bash ssh myserver.com <<EOF echo "Start." CYCLE=$(cat /path/myfile.txt) echo $CYCLE ... echo "End." exit EOF
I get the following error in Jenkins log:
cat: /path/myfile.txt: No such file or directory
I can run same command in terminal console successful. I think the command
$(cat /path/myfile.txt) is executed before the connection to the remote server is up, because of https://stackoverflow.com/a/34074453/4565322. Also 'Start.' was printed after the error message although it should appear before the error message.
How Can I tell my script to wait with the execution of the cat command until the server connection is up?