[Tutor] New to Python

Dave Angel davea at ieee.org
Wed Oct 28 13:16:43 CET 2009


>
> Remember to hit Reply to all
>
> - Forwarding your message onto the list
>
> ---------- Forwarded message ----------
> From: <asterix09 at petlover.com>
> Date: Wed, Oct 28, 2009 at 1:00 AM
> Subject: Re: [Tutor] New to Python
> To: srilyk at gmail.com
>
>
> Hi Wayne,
>
> I will try as best to explain what I need to do.
>
> I have a log file. In that log file thre contains text. Something along the
> lines of this.
>
> 115=WAS
> 115=GAD
> 115=TRE
>
> I need to search that log file (thought of using grep) and write each text
> after the "=" sign to another text file. So the other text file (call it "*
> List*") will contain a list of all the differernt values for 115.
>
> After I have created that, i then need to run a script that will run through
> the latest log file and compare the *List *from the log file and any new
> 115=... values that are not in the* List *text file must be added, vice
> versa.
>
> End result is that I want to track and see how many values I can get in the
> 115=...
>
> The log file is siuated on a different server/machine on my network, so I
> want the script to be able to copy the log file from the server to my
> machine.
>
> I hope that makes sense.
>
>  Many thanks for your help.
>
> -----Original Message-----
> From: Wayne <srilyk at gmail.com>
> To: asterix09 at petlover.com
> Cc: tutor at python.org
> Sent: Tue, Oct 27, 2009 6:53 pm
> Subject: Re: [Tutor] New to Python
>
>  On Tue, Oct 27, 2009 at 10:35 AM, <asterix09 at petlover.com> wrote:
>
>   
>> Hi there,
>>
>> How do you connect to a different server using python? (I have not used
>> python before)
>>
>>     
>
>  What kind of server? What do you ultimately want to do?
>
>  see:  http://catb.org/~esr/faqs/smart-questions.html#beprecise
>
>  for more info about asking good questions. We can't help you if we don't
> know what you want.
> -Wayne
>
>
>   
Did you look up the smart-questions url?

Since you're trying to connect from one Windows XP machine to another 
Windows XP or Server 2003 machine on the same network, the simplest 
answer is to use UNC names, which are machine-name, share-name, and 
path, all rolled into one string with two leading backslashes.

In that case, you can do an open something like the following:
      infile = open(r"\\myserver\share3\system\logs\mylog.txt", "r")

Notice the r" which indicates a raw string, so you wouldn't need to 
double the backslashes.

DaveA



More information about the Tutor mailing list