python - Paramiko change IP of remote machine -


i have change ip of remote machine running gentoo. use code looks like

try:     guest.connect("10.22.254.200", username='root',password='root')     except sshexception detail:         session.flash = detail.message     else:         sftp = guest.open_sftp()         sftp.put('./scripts/change-ip', '/root/change-ip')         sftp.close()         guest.exec_command('chmod +x /root/change-ip')         time.sleep(5)         try:             stdin,stdout,stderr = guest.exec_command('/root/change-ip 10.22.254.200 &') 

my change-ip script looks like

set -x cp /etc/conf.d/net  /etc/conf.d/net.bak sed "s/10.22.254.200/$1/g" /etc/conf.d/net.bak > /etc/conf.d/net /etc/init.d/net.eth0 restart 

i able ssh directly , execute script changing ip, reason cant in code.

any appreciated

restarting network on network dangerous thing. happens here after stopping network interface in command /etc/init.d/net.eth0 restart script receive hangup signal stating connection has been closed, , stops before starting network interface.

to avoid problem, can use nohup, "run command immune hangups".


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -