Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70875 > unrolled thread

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

Started byBhawani Singh <bhawani90@gmail.com>
First post2014-05-02 12:55 -0700
Last post2014-05-02 18:51 -0400
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Hi. I want to create a script to read a file placed in a remote linux server using python..need help..? Bhawani Singh <bhawani90@gmail.com> - 2014-05-02 12:55 -0700
    Re: Hi. I want to create a script to read a file placed in a remote linux server using python..need help..? Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-02 22:32 +0000
      Re: Hi. I want to create a script to read a file placed in a remote linux server using python..need help..? Roy Smith <roy@panix.com> - 2014-05-02 18:51 -0400

#70875 — Hi. I want to create a script to read a file placed in a remote linux server using python..need help..?

FromBhawani Singh <bhawani90@gmail.com>
Date2014-05-02 12:55 -0700
SubjectHi. I want to create a script to read a file placed in a remote linux server using python..need help..?
Message-ID<a6716c27-bd6d-4fc5-8932-55470a78deb2@googlegroups.com>
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..

[toc] | [next] | [standalone]


#70878

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-05-02 22:32 +0000
Message-ID<lk16di$854$1@dont-email.me>
In reply to#70875
On Fri, 02 May 2014 12:55:18 -0700, Bhawani Singh wrote:

> 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.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#70879

FromRoy Smith <roy@panix.com>
Date2014-05-02 18:51 -0400
Message-ID<roy-526263.18512902052014@news.panix.com>
In reply to#70878
In article <lk16di$854$1@dont-email.me>,
 Denis McMahon <denismfmcmahon@gmail.com> wrote:

> 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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web