|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Uploading a File Through FTP
How would I upload a file in C++ through ftp ? I've tried using ftp through system() but it lacks the options i need. Any help would be appreciated
![]() |
|
#2
|
||||
|
||||
|
In what OS?
Are you trying to launch the FTP session from within the program? And then have it run automatically (ie, not interactively)? If so, could you do the same thing in a script? I ask because I've done FTP interactively before, so I know that there is a login procedure and then a series of commands to send. Do you already know a way to do all that within a script? Under Linux/UNIX, that would sound like a job for Expect, which allows you to script sessions with interactive applications -- sorry, I've no actual experience with it. And what options do you need that system() could not provide? Last edited by dwise1_aol : June 12th, 2003 at 10:05 AM. |
|
#3
|
|||
|
|||
|
its under UNIX, (linux, freebsd, darwin) and im using the plain old ftp client. The c++ has the username, password, host, and path stored in variables, i was going to have system excute it all on the ftp program, but ftp doesnt support anything other than specfying the host. And it cant run interactively as it needs to run from cron.
|
|
#4
|
||||
|
||||
|
This can be done from a bash script easily enough.
I do this quite often on RH and using crons to download/upload files to/from a remote server. Code:
#!/bin/sh
#These can be edited.
SERVER=your_server_ip
FTP=/usr/kerberos/bin/ftp
getfile=file_to_get_from_server
#Do not edit below this line.
script=`basename ${0}`.ftp
echo 'user username password' > $script
echo 'verbose' >> $script
echo 'ascii' >> $script
echo 'cd /path/to/file' >> $script
echo "get ${getfile}" >> $script
echo 'bye' >> $script
date > ${script}.log
$FTP -n -u $SERVER < $script >> ${script}.log
rm -f $script
Last edited by Onslaught : June 12th, 2003 at 11:13 AM. |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > Uploading a File Through FTP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|