473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

ftp putting information in a variable

Hello!I am looking for a way to put ftp returns in a variable.My OS is XP and I want to get the owner of a file. So I have to connect to ftp. But I am stacked with how I can receive this information and put it in a variable.Thanks! ArneHere is a intend of doing thisfrom ftplib import FTP
ftp = FTP('ftp.cwi.nl') # connect to host, default port
ftp.login() # user anonymous, passwd anonymous
ftp.retrlines('LIST') # list directory contents.....

Apr 8 '06 #1
1 1439
Hi Arne,

On 2006-04-08 12:44, Arne wrote:
I am looking for a way to put ftp returns in a variable.

My OS is XP and I want to get the owner of a file. So I have to

connect to ftp. But I am stacked with how I can receive this
information and put it in a variable.


you can use a library to handle that. One of them is ftputil
( http://ftputil.sschwarzer.net/ ), which I know because I'm its
author. ;-) Surely, there are alternatives. You can search the
Python package index at http://www.python.org/pypi .

With ftputil, you would do

import ftputil
host = ftputil.FTPHost(hostname, user, password)
# st_uid is used by Python's os.(l)stat, but it's a string here,
# not an integer
user = host.stat(file_or_dir).st_uid
....
host.close()

This works only if the output of the FTP LIST command contains
the user information (which is often the case).

ftputil is pure Python and should work on OS X without problems.

If you think that installing/using an additional library is
overkill, you can extract the necessary parser code from the file
ftp_stat.py or write your own parser.

Stefan
Apr 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dado | last post by:
I lost the point: What is purpose of putting objects to null: If I make a class, JFrame for example, with button which start connection dialog, which is class with connection and statement...
1
by: Mike Vieths | last post by:
I'm running into a problem when I try to run commands with os.execv. It seems to be putting quotation marks around each element of the list passed as its second argument. This is fine for the...
5
by: Zhang Weiwu | last post by:
Hello. I just read a article "rdf in html: approaches" at "http://infomesh.net/2002/rdfinhtml" (guided by google). Looking into the "Embed XML RDF Part II: Embrace Validation" part, there are an...
2
by: Rune Hammerskov | last post by:
I have a javascript where the following line is used prompt the user for a url. # szURL = prompt("Enter a URL:", ""); The problem is that I would like to open a php script instead of the...
5
by: Rhino | last post by:
For DB2 V8 on Windows/Linux/Unix, the idea of having the Information Center online and accessible from IBM via the Internet is probably the best approach for most users. It keeps the information...
5
by: Paul Sijben | last post by:
All, in a worker thread setup that communicates via queues is it possible to catch exceptions raised by the worker executed, put them in an object and send them over the queue to another thread...
4
by: Vernon Wenberg III | last post by:
I'm not really sure how readline() works. Is there a way to iterate through a file with multiple lines and then putting each line in a variable in a loop?
6
by: =?Utf-8?B?bGlhbnF0bGl0?= | last post by:
lets say there are 3 int ncount variable in every method private void x_method1() { int ncount = dv.length; } private void x_method2() { int ncount = drarr.length;
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.