Hi. I want to create a script to read a file placed in a remote linuxserver using python..need help.

B

Bhawani Singh

I have created the script till here ..

import os

os.chdir("/var/log")
fd = open("t1.txt", "r")
for line in fd:
if re.match("(.*)(file1)(.*)", line):
print line,

Output :

file1
 
D

Denis McMahon

I have created the script till here ..

import os

os.chdir("/var/log")
fd = open("t1.txt", "r")
for line in fd:
if re.match("(.*)(file1)(.*)", line):
print line,

Output :

file1

--------------------
this script i ran on the linux server, but now i want to run this script
from another linux server and get the output displayed there..how can i
do that...

i tried to use : pexpect but getting no help..

Method a:

Go and sit in front of the keyboard on the other linux server, run the
script and read the screen.

Method b:

Use telnet to login to your account on the other server, run the script.

To run your script on someone elses machine usually needs you to be able
to access their machine somehow. Either you are permitted to do it, in
which case you should already know how to do it, or you're not permitted
to do it, in which case we're not going to teach you how to do it here.
 
R

Roy Smith

Denis McMahon said:
Method b:

Use telnet to login to your account on the other server, run the script.

Ugh. I hope nobody is using telnet anymore. Passwords send in plain
text over the network. Bad. All uses of telnet should have long since
been replaced with ssh.

One of the cool thinks about ssh is that not only does it give you
remote shell connectivity, but it can be used to execute commands
remotely, over the same secure channel. There is an awesome python
package called fabric (http://www.fabfile.org/) which makes it trivial
to do this inside of a python program. You can use it as a command-line
tool, or as a library embedded in another python script.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top