i am trying to execute the following script to a remote machine via ssh :


git clone https://github.com/vmwarelab/oc-electro-theme.git

cd ./oc-electro-theme

mysql -u ocuser opencart < cmd.txt


i thought each command will simply wait until the command before it is complete but what ends up happening, the 2nd command "cd" executes trying to change to the folder before git clone finishes resulting in a failure..

if i put sleep for 60 sec "sleep 60" it endup adding carriage return to it and get passed as "sleep 60\r" which turns it into an invalid syntax

is that the expected behaviour ? how can i fix that ? any help is much appriciated


it was because we were doing copy and pasting the script content from windows there for adding the carriage return to end of each of the lines within the script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.