Bash 脚本 - 如何自动执行 nano 命令?
Bash Script - How to automate a nano command?
如何不使用 nano 命令编辑保存在远程服务器(从终端)上的文件?
这里是要注入的代码
import sys
sys.path.append('/opt/lib/python2.5/site-packages')
我试图解决这个问题,即不使用 nano 命令使用 wget+cat 写入文件位置,它似乎有效。
wget https://REMOTE_SERVER_URL/HTTPRequest.py
cat HTTPRequest.py > /opt/share/pyload/module/network/HTTPRequest.py
但是这里有些错误,脚本正确保存后"pyload"
wget https://REMOTE_SERVER_URL/pyload
cat pyload > /etc/init.d/pyload
chmod 755 /etc/init.d/pyload
然后说
update-rc.d: warning: /etc/init.d/pyload missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/pyload ...
/etc/rc0.d/K20pyload -> ../init.d/pyload
/etc/rc1.d/K20pyload -> ../init.d/pyload
/etc/rc6.d/K20pyload -> ../init.d/pyload
/etc/rc2.d/S20pyload -> ../init.d/pyload
/etc/rc3.d/S20pyload -> ../init.d/pyload
/etc/rc4.d/S20pyload -> ../init.d/pyload
/etc/rc5.d/S20pyload -> ../init.d/pyload
EDIT23NOV:清除代码
不要用nano
,可以用sed
,可以是
sed -i '/import pycurl/i \
import sys \
sys.path.append("/opt/lib/python2.5/site-packages")' opt/share/pyload/module/network/HTTPRequest.py
我没有测试它,所以也许你应该转义附加内的斜杠。
首先,备份文件,因为 -i
修饰符会覆盖您的文件
如何不使用 nano 命令编辑保存在远程服务器(从终端)上的文件?
这里是要注入的代码
import sys
sys.path.append('/opt/lib/python2.5/site-packages')
我试图解决这个问题,即不使用 nano 命令使用 wget+cat 写入文件位置,它似乎有效。
wget https://REMOTE_SERVER_URL/HTTPRequest.py
cat HTTPRequest.py > /opt/share/pyload/module/network/HTTPRequest.py
但是这里有些错误,脚本正确保存后"pyload"
wget https://REMOTE_SERVER_URL/pyload
cat pyload > /etc/init.d/pyload
chmod 755 /etc/init.d/pyload
然后说
update-rc.d: warning: /etc/init.d/pyload missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/pyload ...
/etc/rc0.d/K20pyload -> ../init.d/pyload
/etc/rc1.d/K20pyload -> ../init.d/pyload
/etc/rc6.d/K20pyload -> ../init.d/pyload
/etc/rc2.d/S20pyload -> ../init.d/pyload
/etc/rc3.d/S20pyload -> ../init.d/pyload
/etc/rc4.d/S20pyload -> ../init.d/pyload
/etc/rc5.d/S20pyload -> ../init.d/pyload
EDIT23NOV:清除代码
不要用nano
,可以用sed
,可以是
sed -i '/import pycurl/i \
import sys \
sys.path.append("/opt/lib/python2.5/site-packages")' opt/share/pyload/module/network/HTTPRequest.py
我没有测试它,所以也许你应该转义附加内的斜杠。
首先,备份文件,因为 -i
修饰符会覆盖您的文件