使用putty -m选项提供“未找到的命令”

时间:2023-02-03 17:14:58

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.

如果我用putty -load session_name打开一个shell,然后执行一个命令,将作业添加到linux系统(qsub -cwd -b主机名)上的网格队列中,一切都很正常。

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

但是如果我将命令添加到文本文件中,然后执行putty -load session_name -m文件。txt,我得到qsub:命令未找到。

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

如果我退出并将文本文件简化为只有命令主机名并使用-m选项,它也可以正常工作。

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.

如果我使用连接->SSH->远程命令,并执行类似于-m命令的操作,我将得到与命令行相同的结果。

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...

在linux系统中,我是一个新手,这似乎应该是一个简单的修复,来告诉我们“qsub”存在于某个地方。或者是对这些远程访问的限制。

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.

好的,最初的问题是如何运行它——我算出了(添加一条绝对路径),但是还有其他环境变量问题。看起来qsub需要设置SGE_ROOT变量,但是对于远程命令窗口也没有设置。

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?

因此,一个更好的问题是,如何让putty远程命令shell(使用-m)打开与手动命令行shell相同的属性和设置?

1 个解决方案

#1


1  

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.

当您在交互式地登录时,qsub在您的路径上,但是在非交互式shell中,它不是。在脚本中给出完整的路径,或者在脚本中设置路径,您应该解决您的问题。

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.

似乎您需要在交互式会话上下文中运行您的命令,但是sshd协议并不直接这样做。因此,尝试通过/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.

我将shell初始化为一个交互式的shell,因此它将加载您的.profile或.bashrc中的所有环境变量,这些变量都被加载到一个真正的交互式shell中。c提供了在交互式shell中运行的命令。

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

因为它在交互式会话中工作,所以您不应该这样显式地设置任何路径。

#1


1  

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.

当您在交互式地登录时,qsub在您的路径上,但是在非交互式shell中,它不是。在脚本中给出完整的路径,或者在脚本中设置路径,您应该解决您的问题。

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.

似乎您需要在交互式会话上下文中运行您的命令,但是sshd协议并不直接这样做。因此,尝试通过/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.

我将shell初始化为一个交互式的shell,因此它将加载您的.profile或.bashrc中的所有环境变量,这些变量都被加载到一个真正的交互式shell中。c提供了在交互式shell中运行的命令。

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

因为它在交互式会话中工作,所以您不应该这样显式地设置任何路径。