Re: [Tutor] updating Unix config file

2009-10-20 Thread Matt Herzog
On Tue, Oct 20, 2009 at 07:53:17AM -0700, Steve Willoughby wrote: > On Tue, Oct 20, 2009 at 10:44:16AM -0400, Matt Herzog wrote: > > Yes, thanks. What failed was the invocation of PIPE. Apparently I had to > > explicitly import PIPE from subprocess or python had no clue as to wha

Re: [Tutor] updating Unix config file

2009-10-20 Thread Matt Herzog
On Tue, Oct 20, 2009 at 02:49:53PM +, Tiago Saboga wrote: > On Tue, Oct 20, 2009 at 2:44 PM, Matt Herzog wrote: > > Yes, thanks. What failed was the invocation of PIPE. Apparently I had to > > explicitly import PIPE from subprocess or python had no clue as to what > > P

Re: [Tutor] updating Unix config file

2009-10-20 Thread Matt Herzog
On Tue, Oct 20, 2009 at 08:29:59AM +0100, Alan Gauld wrote: > "Matt Herzog" wrote > > >Anyway, I'd like a hint as to how I could convert this: > > > >ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines() > >x = string.split(ifcfg_lines[3

Re: [Tutor] updating Unix config file

2009-10-19 Thread Matt Herzog
On Mon, Oct 19, 2009 at 07:51:06PM -0400, Matt Herzog wrote: > On Mon, Oct 19, 2009 at 08:07:47PM +0100, Alan Gauld wrote: > > > > "Matt Herzog" wrote > > > > >remembered that strings are immutable. > > >So how was I able to change the

Re: [Tutor] updating Unix config file

2009-10-19 Thread Matt Herzog
On Mon, Oct 19, 2009 at 08:07:47PM +0100, Alan Gauld wrote: > > "Matt Herzog" wrote > > >remembered that strings are immutable. > >So how was I able to change the strings for my dotted quad? > > You didn't. > > >LASTKNOWN = '173.48.204

[Tutor] updating Unix config file

2009-10-19 Thread Matt Herzog
Hi All. The below script seems to work well enough to use but I'm wondering if I'm doing the file edit stuff in a "kosher" manner. I was just reading the Lutz O'Reilly "Learning" book and remembered that strings are immutable. So how was I able to change the strings for my dotted quad? I did no

Re: [Tutor] sftp get single file

2009-07-20 Thread Matt Herzog
On Mon, Jul 20, 2009 at 05:26:09PM -0500, Wayne wrote: > On Mon, Jul 20, 2009 at 5:18 PM, Matt Herzog wrote: > > > On Mon, Jul 20, 2009 at 11:57:57PM +0200, Sander Sweers wrote: > > > Please reply to the list. > > > > > > 2009/7/20 Matt Herzog : > >

Re: [Tutor] sftp get single file

2009-07-20 Thread Matt Herzog
On Mon, Jul 20, 2009 at 11:57:57PM +0200, Sander Sweers wrote: > Please reply to the list. > > 2009/7/20 Matt Herzog : > > Yeah. I have no idea if I am able to do this. The jail makes it ambiguous. > > There is no difference, the jail just moves the root directory as

[Tutor] paramiko list user said,

2009-07-20 Thread Matt Herzog
A user of the paramiko mailing list said, "Paramiko has an SFTPClient class and an SSHClient that can be used to transfer files, why complicate it by using a Transport directly. The easiest thing is to open an SSHClient:

Re: [Tutor] sftp get single file

2009-07-20 Thread Matt Herzog
If I change remotepath = 'datestr' to remotepath = datestr I get: sftp.get(remotepath, localpath) File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 587, in get IOError: [Errno 21] Is a directory: '/tmp/testor/' So remotepath is really more like a path + filname. So I ne

Re: [Tutor] sftp get single file

2009-07-20 Thread Matt Herzog
On Mon, Jul 20, 2009 at 11:02:52PM +0200, Sander Sweers wrote: > 2009/7/20 Matt Herzog : > > Traceback (most recent call last): > > ??File "./scpgetter.py", line 20, in ? > > ?? ?? ??sftp.get(remotepath, localpath) > > ?? ?? ?? ??File "build/bdis

Re: [Tutor] sftp get single file

2009-07-20 Thread Matt Herzog
On Mon, Jul 20, 2009 at 10:22:37PM +0200, Sander Sweers wrote: > I do not know paramiko but looking over the client documentations... > > 2009/7/20 Matt Herzog : > > if __name__ == "__main__": > >t = paramiko.Transport((hostname, port)) > >t.connect

Re: [Tutor] sftp get single file

2009-07-20 Thread Matt Herzog
On Fri, Jul 17, 2009 at 12:12:52PM -0400, Kent Johnson wrote: > On Fri, Jul 17, 2009 at 11:42 AM, Sander Sweers > wrote: > > > import time > > > > today = time.localtime() > > datestr = time.strftime("%Y%m%d",today) > > ext = ".tab" > > > > print datestr + ext > > You can include literal charact

[Tutor] sftp get single file

2009-07-17 Thread Matt Herzog
Hello All. I need to use paramiko to sftp get a single file from a remote server. The remote file's base name will be today's date (%Y%m%d) dot tab. I need help joining the today with the .tab extension. Do I need globbing? example: 20090716.tab #!/usr/bin/env python import paramiko import glob

[Tutor] simply moving files

2009-05-12 Thread Matt Herzog
On monday I posted the below code: def schmove(src,dst): ... src = '/home/datasvcs/PIG/cjomeda_exp/' ... dst = '/home/datasvcs/PIG/cjomeda_exp_archive/' ... listOfFiles = os.listdir(src) ... for filez in listOfFiles: ... os.system("mv"+ " " + src + " " +

[Tutor] moving files from one dir to another

2009-05-11 Thread Matt Herzog
Should be simple, right? Not for me, heh. def schmove(src,dst): ... src = '/home/datasvcs/PIG/cjomeda_exp/' ... dst = '/home/datasvcs/PIG/cjomeda_exp_archive/' ... listOfFiles = os.listdir(src) ... for filez in listOfFiles: ... os.system("mv"+ " " + src

Re: [Tutor] paramiko again

2009-05-09 Thread Matt Herzog
On Sun, May 10, 2009 at 12:53:49AM +0100, Alan Gauld wrote: > Have you used normal ftp in its command line version? > The put command specifies the location on the remote machine > where you want to store the files. This is normal ftp behaviour. The server supports only sftp. Yeah, I could turn o

[Tutor] paramiko again

2009-05-09 Thread Matt Herzog
Hello again. This code comes straight from the http://oreilly.com/catalog/9780596515829/ book. The only actual code I changed was s/get/put on the second to last line. The author says I ought to be able to do this and have it Just Work. There are several things I don't understand. Would be nic

Re: [Tutor] glob paramiko

2009-05-08 Thread Matt Herzog
On Fri, May 08, 2009 at 02:30:22PM -0400, Kent Johnson wrote: > On Fri, May 8, 2009 at 1:04 PM, Matt Herzog wrote: > > Hey All. > > > > All I need to do in this script is scp or sftp a bunch of files to a remote > > server. This script will run from a cron job event

[Tutor] glob paramiko

2009-05-08 Thread Matt Herzog
Hey All. All I need to do in this script is scp or sftp a bunch of files to a remote server. This script will run from a cron job eventually. For whatever reason, paramiko can't cope with a list. --- AttributeError

Re: [Tutor] Redux: optparse

2008-12-27 Thread Matt Herzog
> Do you want to use optparse, or get the command line arguments yourself? > It seems the pattern string will be the first arg, will it? Again I am confused. I assumed that optparse was the best way to pass in arguments (such as filenames) from the command line. Like so: ./script.py -x r

[Tutor] Redux: optparse

2008-12-27 Thread Matt Herzog
On Wed, Dec 24, 2008 at 01:12:55AM -, Alan Gauld wrote: > > "Kent Johnson" wrote > > >> for filename in os.listdir(directory): > >> result = re.match(s, filename) > >> print result > > > >You never open and read the files. You are searching for the pattern > >in the filenam

[Tutor] optparse

2008-12-23 Thread Matt Herzog
Hi All. I want to write a script that will emulate grep to some extent. This is just an exercise for me. I want to run the script like this: ./pythongrep directory searchstring Just like grep, I want it to print: filename, instance_of_match As of now, the script can't find anything I tell it t

Re: [Tutor] Equivalent of grep in python

2008-12-21 Thread Matt Herzog
- Forwarded message from Tiago Katcipis - i forgot, this might help you http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files I can't help wondering how to do this in python: perl -wnl -e '/string/ and print;' filename(s) Not that I want to forget the pre