How can I edit a file saved on a remote server (from Terminal) not using nano command?
Here the code to inject
import sys
sys.path.append('/opt/lib/python2.5/site-packages')
I tried to solve this problem of writing not using nano command using wget+cat to file location and it seems to work.
wget https://REMOTE_SERVER_URL/HTTPRequest.py
cat HTTPRequest.py > /opt/share/pyload/module/network/HTTPRequest.py
But there are some errors here, after the script correctly saves "pyload"
wget https://REMOTE_SERVER_URL/pyload
cat pyload > /etc/init.d/pyload
chmod 755 /etc/init.d/pyload
It then says
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: cleared the code
Don't use nano
, you can use sed
, could be something like
sed -i '/import pycurl/i \
import sys \
sys.path.append("/opt/lib/python2.5/site-packages")' opt/share/pyload/module/network/HTTPRequest.py
I didn't test it so maybe you should escape the slashes inside the append.
And first, do a backup of the file because the -i
modifier will overwrite your file