I would attempt to put the arguments to `ssh` in double quotes. ssh usr@machene_wehere_i_run_the_code "/home/run_dir_script/run.sh inp 8" Also based on that error message it sounds like the script cannot find this script: > /home/run_dir_script/run.sh: line 59: /home/run_dir_script/merge_tabs.sh: No such file or directory Also I'd block the `scp` from happening if the `ssh` doesn't return a successful status: ssh usr@machene_wehere_i_run_the_code "/home/run_dir_script/run.sh inp 8" status=$? if $status; then scp -p usr@machene_wehere_i_run_the_code:/home/run_dir_script/results \ user@machine_where_the_resutlst_are_needed:~/ fi