473,320 Members | 1,854 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,320 software developers and data experts.

Using variable in storbinary function of ftpilb module

Hi,

I am new to python.

I have written a simple code to upload a file via ftp to remote server

-------------
import sys
import ftplib
host=sys.argv[1]
username=sys.argv[2]
passwd=sys.argv[3]
filename=sys.argv[4]

print host,username,passwd

ftp = ftplib.FTP(host,username,passwd)
fd=open(filename,'rb')
ftp.storbinary('STOR filename',fd)
-------------------

I am passing file name in cmd line arg. but I have no idea how to use "filename" variable value in ftp.storbinary('STOR filename',fd) ?

Oct 15 '08 #1
1 3112
Arya, Manish Kumar wrote:
Hi,

I am new to python.

I have written a simple code to upload a file via ftp to remote server

-------------
import sys
import ftplib
host=sys.argv[1]
username=sys.argv[2]
passwd=sys.argv[3]
filename=sys.argv[4]

print host,username,passwd

ftp = ftplib.FTP(host,username,passwd)
fd=open(filename,'rb')
ftp.storbinary('STOR filename',fd)
-------------------

I am passing file name in cmd line arg. but I have no idea how to use
"filename" variable value in ftp.storbinary('STOR filename',fd) ?
ftp.storbinary("STOR %s" % filename, fd)

Diez
Oct 15 '08 #2

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

Similar topics

9
by: Charley Kyd | last post by:
I'm a newbie who needs advice about how to use external files of JavaScript code. I spent an hour this afternoon browsing through JavaScript books at the local book store. In about 15 different...
2
by: Henry | last post by:
Hi guys, I want to write some global functions which can be called from different asp.net page. In Visual Basic, there is a global module which allow me to do that. In Visual Basic .net, I...
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
8
by: Jeff | last post by:
Still new to vb.net in VS2005 web developer... What is the proper/standard way of doing the following - setting the value of a variable in one sub and calling it from another? E.g., as below....
2
by: Shraddha | last post by:
Can we declare extern variable as static? What will be the scope of the variable then? What if we change the value of the variable in some other function? Also can someone tell me that if we can...
1
by: fredniggle | last post by:
Hello again, After searching over many sources, and examples, I am still experiencing trouble with uploading files to a FTP server. Can any explain the differences between storlines and...
2
by: panteraboy | last post by:
Hello again Humble helpfulls. Im having difficult with a module i have created. As its my first it was never going to be straightforward lol. But I was looking at one of the other treads and found it...
0
by: Joe Strout | last post by:
Hi Luis, A static variable IS encapsulation. Encapsulation happens at many levels: module, class, instance, and (in languages that support it) method. A static local variable is simply the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.