0
votes

If I open a shell into a machine with: putty -load session_name and then execute a command to add a job to a Grid queue on a linux system (qsub -cwd -b hostname), everything works fine.

But if I add the command to a text file, and then do putty -load session_name -m file.txt, I get qsub: command not found

If I back out and simplify the text file to be only the command hostname and use the -m option, it also works fine.

If I use the Connection->SSH->Remote command, and do something similar as the -m command, I get the same results as from the command line.

I'm very much a novice at linux systems, and this seems like it should be a simple fix to tell something that 'qsub' exists somewhere. Either that or there are some restrictions on these remote access things...

Edit:

Ok, so the initial question was how to run it--and I figured that out (add an absolute path), but there are other environment variable issues as well. It appears that qsub requires the SGE_ROOT variable to be set, but that isn't set for the remote commands window either.

So, a better question is, how do I get the putty remote commands shell (using -m) to open with the same properties and setup as a manual command line shell?

1

1 Answers

1
votes

qsub is on your path when you log in interactively, but in the non-interactive shell it is not. Give the full path in the script, or set PATH in the script, and you ought to fix your problem.

It seems you need to run your command in the context of an interactive session, but the sshd protocol doesn't directly do that. So try invoking the command indirectly through /bin/sh.

/bin/sh -i -c "qsub -cwd -b hostname"

The -i makes the shell initialize itself like an interactive one, so it will load all the environment variables in your .profile or .bashrc that are loaded in a real interactive shell. The -c provides a command to run within that interactive shell.

You shouldn't have to explicitly set any paths this way since it works in an interactive session.