Why do u say so??? I have been following the advices and found some of them useful...Well, in the previous thread, I had replied to your post with my problem and you didn't bother to reply...well thanx for the advices
@grib:
I want to do it from inside a script, neither urllib.urlopen nor the built in open helped me
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("computer_name",
username="username", password="password", allow_agent = False)
def home_dir(user):
return "/cygdrive/c/Documents*Settings/" + user
# get the content of a user's home dir on the remote machine
i, o, e = ssh.exec_command("ls " + home_dir("username"))
# download a remote file
ftp = ssh.open_sftp()
ftp.get("remote_path/filename" , "local_path/filename")
ftp.close()
my guide suggested me to prefer telnet over ssh, as it is widely used. so I am thinking of using the module 'telnetlib'.
I am doing the following:
import telnetlib
...........
........
..........
user=User
password=pass
telnet=telnetlib.Telnet(host)
telnet.write(user+'\r\n')
telnet.write(password+'\r\n')after this, i need to check whether a folder exists on that host and if present, do an FTP upload.. how do I proceed?
my guide suggested me to prefer telnet over ssh, as it is widely used. so I am thinking of using the module 'telnetlib'.
I am doing the following:
import telnetlib
...........
........
..........
user=User
password=pass
telnet=telnetlib.Telnet(host)
telnet.write(user+'\r\n')
telnet.write(password+'\r\n')after this, i need to check whether a folder exists on that host and if present, do an FTP upload.. how do I proceed?
Apparently, you must write a command and then read until the prompt is sent, something
like
telnet.write("cd path/to/your/folder\n")
data = telnet.read_until("$ ")
But I think you should have read also with your 2 first writes for the user and the password. You should start by testing this activestate recipe http://code.activestate.com/recipes/52228/
To download a file, try telnet.write("get filename\n"). You should also obtain a list of available commands with telnet.write("help\n") etc. If you never ran telnet by hand in a terminal, it would be a good idea to do it.
I tried it, bu it gives "none" no matter the file is present or not.
Learnt that linux stores the return value of recently executed command in the variable $?. Is there any way of copying the value of $?of remote host onto a variable in the host where i run the script?
I tried it, bu it gives "none" no matter the file is present or not.
Learnt that linux stores the return value of recently executed command in the variable $?. Is there any way of copying the value of $?of remote host onto a variable in the host where i run the script?
I don't think you can get $*. I can't help you because I don't have a telnet server to connect to ...
is there any way to save output of individual commands over telnet session onto seperate variables instead of using Telnet.read_all() at the end? or
is there any way to save the output of Telnet.read_all() to a file , so that the output can be parsed?
is there any way to save output of individual commands over telnet session onto seperate variables instead of using Telnet.read_all() at the end? or
is there any way to save the output of Telnet.read_all() to a file , so that the output can be parsed?
Look more carefully in the activestate recipe. At line 46, there is a 'print response' statement. It means that the code displays the result of the commands. You should be able to do the same in your code. Use read_until() instead of read_all().
Dear Friends, I am facing a problem, I have two forms,
Form1 Has one DataGrideview and Button redirect to Form2, which has Button(Browse Excel File) and combobox(Sheet No of excel ...