正如 Adel 所说,使用远程系统资源管理器或普通的“运行”按钮可能无法做到这一点,
但您可以自动化您当前使用的流程。风扇坏了我不得不这样做几个星期
在我的笔记本电脑中,在那里进行任何重要的计算都会导致它过热和断电,所以我只是跑了
一切都在我的工作机器上。
您可以使用外部工具机制运行一个简短的脚本,将您的代码同步到远程服务器,
运行您的脚本,然后将任何输出文件同步回您的本地计算机。我的脚本看起来像这样,
存储在 $HOME/bin/runremote.sh 中,可执行 (chmod +x runremote.sh)
fp="$1" # Local path to the script we want to run--for now,
# this is the only command I pass in from Eclipse, but you could add others if so inclined.
# My home directory is a little different on my local machine than on the remote,
# but otherwise things are in the same place. Adjust as needed.
fp=`python -c "print '$fp'.replace('/home/tsbertalan', '/home/oakridge/bertalan')"`
# Run the synchronization. I use Unison, but you could use something else,
# like two calls to rsync, or a series of scp commands.
reposync >/dev/null # The redirection assumes your sync command will print errors properly on stderr.
cd='cd '`dirname $fp`
# I use a virtual environment on the remote server, since I don't have root access to install
# packages globally. But this could be any set-up command you want to run on the remote.
# A good alternative would be `source $HOME/.profile` or `~/.bashrc`.
act='source /home/oakridge/bertalan/bin/activate'
fname="`basename $fp`"
cmd="$act ; $cd ; python $fname"
# Run the command remotely. The -X forwards X11 windows, so you can see your Matplotlib plots.
# One difficulty with this method is that you might not see all your output just as it is created.
ssh bertalan@remote.server.edu -X "$cmd"
sleep 1
# My synchronization script is bidirectional, but you could just use rsync with the arguments flipped.
reposync >/dev/null
如果你不在本地使用 linux 或 OSX,你可能不得不使用 MinGW 或 Cygwin 或其他任何东西来获得
这个工作。或者,由于您似乎有一个工作的 Python 解释器,您可以编写一个
Python中的等效脚本,使其可执行(我认为是通过资源管理器中的文件属性对话框),
并在顶部添加 #!/path/to/python 行。我不经常使用 Windows,所以对此我无能为力。
要在 Eclipse 中使用它,请转到 Run > External Tools > External Tools Configurations.... 添加新工具
其位置是脚本的路径,其第一个参数是 ${resource_loc}。
然后,您可以将其与 Run > External Tools > [first item] 一起使用,或将其绑定到键盘快捷键(我使用 F12)
转到 Windows > Preferences > Keys,然后搜索“Run Last Launched External Tool”。想必你会
必须先浏览菜单才能使其成为“最后启动”的外部工具。