I'm using some old Fortran code that uses some peculiar memory handling. To make the long story short, it runs on my local machine but fails on the remote one. This is why I would like to
ssh to my local computer run the code and copy the results back to the cluster I'm running my calculations on.
I already found exactly the same question on this forum:
After the comment by @Anthon, I corrected my script, unfortunately new error occurred. NOTE: I am using ssh keys so no passwords are needed.My new script:
#! /bin/bash # start form the machine_where_the_resutlst_are_needed ssh usr@machene_wehere_i_run_the_code /home/run_dir_script/run.sh inp 8 # do the work by running a script. 8 jobs are run by sending them # to the background, scp -p usr@machene_wehere_i_run_the_code:/home/run_dir_script/results \ user@machine_where_the_resutlst_are_needed:~/ echo "I am back"
My problem is that
run.sh is a master script calling other shell scripts, and they don't run properly. I get the following message:
/home/run_dir_script/run.sh: line 59: /home/run_dir_script/merge_tabs.sh: No such file or directory
Here is a condensed example of what I am doing
#! /usr/bin/bash pwd echo "Run the code" ./HELLO_WORLD
The above script is run by
ssh usr@machene_wehere_i_run_the_code /home/run_dir_script/run.sh
For completeness the fortran code ./HELLO_WORLD
program main write(*,*) 'Hello World' stop end
Compile with gfortran -o HELLO_WORLD hello_world.F90
And here is the output
/home/run_dir_script/ Run the code /home/run_dir_script/test.sh: line 5: ./home/HELLO_WORLD: No such file or directory
The following will run `HELLO_WORLD` on the remote machine ssh usr@machene_wehere_i_run_the_code /home/run_dir_script/HELLO_WORLD
So calling the code directly works fine. Calling it via the script fails.
The reason why this fails is due to the fact that after ssh I land in my remote machine's
Therefore before executing the script, I have to
cd in the proper directory. The correct method, besides giving absolute path is:
Another useful remark, is that I all the variables from .bashrc are undefined. Therefore one has to be careful.
usr@machene_wehere_i_run_the_code "cd /home/run_dir_script ; run.sh"
So this somehow works