如何远程登录Linux机器并运行Python程序

如何远程登录Linux机器并运行Python程序,第1张

新手对于没有图形界面的linux远程登录及其 *** 作都充满畏惧。这里介绍一个简单的软件。叫作BitViz。简称BV for short。

一、软件安装

这里使用Putty的一个client软件叫作Bv SshClient. 你可以在putty的官网上找到其链接。

Bitvise Tunnelier

Tunnelier is an SSH and SFTP client for Windows. It is developed and supported professionally by Bitvise. Tunnelier is robust, easy to install, easy to use, and supports all features supported by PuTTY, as well as the following:

graphical SFTP file transfer图形界面最喜欢

single-click Remote Desktop tunneling

auto-reconnecting capability

dynamic port forwarding through an integrated proxy

an FTP-to-SFTP protocol bridge. 方便的上传下载和删除 *** 作。

Tunnelier is free for personal use, as well as for individual commercial use inside organizations. You can download Tunnelier here. ownload-area

二、熟悉窗口

下面一个例子,是找到python软件安装位置的演示:

1. 首先,我进入到root

步骤一,进入root

2. 输入/home

步骤二,进入home

3. 点击其中子文件夹,即可找到,方便了。

步骤三,找到python文件夹

三、easy_install python library

Example Of python-setuptools Being Installed:

[root@server ~]# yum install python-setuptools

Yum Command To Install python-setuptools-devel:

[root@server ~]# yum install python-setuptools-devel

在linux 下: 使用方法非常简单,在命令行输入“easy_install 参数”即可。

这比我想象的要方便很多!在windows里,我要cmd-cd &easy_install flickrapi

在ssh的命令窗口,只需输入 easy_install flickrapi

如下图:

easy_install flickrapi

四、run python script as a background process in linux

So, you have a server to which you connect remotely, upload a python script and want to run it and logout from the server keeping the program running. If you frequently work with spiders, you surely want to do it. But how to do it? For example if your script's name is script.py, then the command is:

[root@server ~]# nohup python script.py &

And sometimes you may be interested to see the output is that being generated. Then you should view the nohup.out file! This command can be useful:

[root@server ~]# tail -f nohup.out

看看效果!

有两种方式:\x0d\x0a1、直接使用pythonxxxx.py执行。其中python可以写成python的绝对路径。使用whichpython进行查询。\x0d\x0a2、在文件的头部(第一行)写上#!/usr/bin/python2.7,这个地方使用python的绝对路径,就是上面用whichpython查询来的结果。然后在外面就可以使用./xxx.py执行了。\x0d\x0a\x0d\x0a因为在linux中,python啊shell这些程序都是普通的文本格式,都需要一种程序去解释执行它。要么调用的时候指定,要么在文件头指定。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/7538665.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-06
下一篇 2023-04-06

发表评论

登录后才能评论

评论列表(0条)

保存