according to my code ( it takes host from command line argument)
#!usr/bin/python
import sys
import telnetlib
import subprocess
import os
import commands
user = "test"
password = "test"
tn = telnetlib.Telnet(sys.argv[1])
tn.read_until("login: ")
tn.write(user + "\n")
tn.read_until("Password: ")
tn.write(password + "\n")
pipe = os.popen("pwd","w")
print pipe
pipe3 = os.popen("cd /tftpboot/")
print pipe3
pipe1 = os.popen("pwd","w")
print pipe1
tn.write("exit\n")
print "exit"
here the output for pipe is "/" and for pipe1 is also "/" unable to change directory through this script.
os.popen("cd ....")
affect only the subprocess. Instead use os.chdir
:
os.chdir("/tftpboot")