Search : in
By :

Script to extract files info from ftp server

Last answer on Apr 29, 2009 8:00:27 am BST aiko27, on Sep 22, 2008 9:53:09 pm BST 
 Report this message to moderators

Hi

Wonder if you could help me with the following please.

I would like to construct a script (in any language whichever it's easiest) which when run, it will log on to an existing ftp server using a generic account and password, then list the files in a specific folder that begins with the string "abc". The file names along with their creation date are then to be extracted on a csv file (or similar). Can any one be able to help me on this please?

Many thanks in advance!!

Best answers for « Script to extract files info from ftp server » in :
Connecting to a Ftp server under Ms-Dos Show Connecting to a Ftp server under Ms-Dos The ftp command allows you to get connected using command lines. Some of these options provide an automatic connection; this is done through a list of commands store on a text file. ftp -i ...
FTP Servers and file sharing Show FTP Servers and file sharing! FTP Servers The Web Server (HTTP) Hosting Website for temporary files Rapidshare Sending large files to friends using e-mail is not always easy. Most mail servers do not accept files larger than 5MB...
Access to an FTP server as if it were a local directory ShowAccess to an FTP server as if it were a local directory Install Curlftpfs : sudo aptitude install curlftpfs Create the directory for FTP server: mkdir mountpoint Add authorized users to use the software(fuse group): sudo...
How to read a file line by line ShowHow to read a file line by line Intro Tips Bonus Intro One of the most common errors of learning scripts bash on GNU / Linux is to read a file line by line, is to use a loop "for" (for line in $ (cat file.txt) do. ..), which in this...
Deleting the uninstall files for SP1 & 2 under Vista ShowDeleting the uninstall files for SP1 & 2 under Vista This trick allows you to earn more than 700 mb on the system partition by removing the backup files created after installation the service pack (1 and 2). However, after deleting...
FTP protocol (File Transfer Protocol) ShowIntroduction to FTP protocol FTP protocol (File Transfer Protocol) is, as its name indicates a protocol for transferring files. The implementation of FTP dates from 1971 when a file transfer system (described in RFC141) between MIT machines...
Using FTP commands ShowThe FTP protocol FTP (File Transfer Protocol) is a protocol — meaning a standard language that lets two machines communicate — used so that computers of different types (or with different operating systems) can transfer files over a...

1

Fred, on Oct 15, 2008 2:47:06 pm BST
  • +5

If it's under Windows, you must use win32 api
You can ask on specialized Win32 api newsgroup :
news://194.177.96.26/comp.os.ms-windows.programmer.win32

Reply to Fred

2

cb4nd17, on Nov 21, 2008 6:53:23 pm GMT
  • +18

Ftp.Hostname = "ftp.test.com"
ftp.Username = "User"
ftp.Password = "Pass"

' The default data transfer mode is "Active" as opposed to "Passive".
' Change it to Passive by setting the Passive property:
ftp.Passive = 1

' Establish an AUTH SSL secure channel after connection
' on the standard FTP port 21.
ftp.AuthTls = 1

' The Ssl property is for establishing an implicit SSL connection
' on port 990. Do not set it.
ftp.Ssl = 0
' Connect and login to the FTP server.
connectStatus = ftp.Connect()
If (connectStatus <> 1) Then
'MsgBox ftp.LastErrorText
'WScript.Quit
Main = DTSTaskExecResult_Failure
Else
dirStatus = ftp.ChangeRemoteDir("RMed")
If (dirStatus <> 1) Then
'MsgBox ftp.LastErrorText
'WScript.Quit
Main = DTSTaskExecResult_Failure
End If



'MsgBox ftp.getCurrentRemoteDir()

'specify the file path and name on the local machine
localInvoiceFile = "C:\Documents and Settings\Nathan\My Documents\2\dRMed\Invoice_RMed.txt"
localPatientFile = "C:\Documents and Settings\Nathan\My Documents\2\dRMed\Patient_RMed.txt"

'specify the file path and name on the remote machine
remoteInvoiceFile = "C:\Clients\Strat\File Uploads\Customer Uploads\RMed\Invoice_RMed.txt"
remotePatientFile = "C:\Clients\Strat\File Uploads\Customer Uploads\RMed\Patient_RMed.txt"
'MsgBox remoteInvoiceFile
'MsgBox remotePatientFile

'download the files from the remote server
transferStatus = ftp.getFile(remoteInvoiceFile, localInvoiceFile)
if (transferStatus <> 1) then
'MsgBox ftp.LastErrorText
Main = DTSTaskExecResult_Failure
else
Main = DTSTaskExecResult_Success
end if

transferStatus = ftp.GetFile(remotePatientFile, localPatientFile)
if (transferStatus <> 1) then
'MsgBox ftp.LastErrorText
Main = DTSTaskExecResult_Failure
else
Main = DTSTaskExecResult_Success
end if

END IF
ftp.Disconnect

End Function

Reply to cb4nd17

4

PHDenver, on Jan 13, 2009 10:46:38 pm GMT
  • +15

I saw your reply about scripting and was wondering if I could hire you to write a similar script?

Reply to PHDenver

5

pat, on Jan 14, 2009 12:37:48 pm GMT
  • +1

See all MSDN scripts samples.
Everything is there

Reply to pat

7

rinky, on Apr 13, 2009 9:36:53 am BST
  • +3

I have to write a script in shell.down load the files from FTP which are updated on month of january, April, aug, december.how i write this in shell scripting.plz give me the solution.

Reply to rinky

8

rinky, on Apr 13, 2009 10:02:57 am BST
  • +6

I have to write a script in shell.down load the files from FTP which are updated on month of january, April, aug, december & how i run the job every 1st week of each quarterhow I write this in shell scripting.plz give me the solution.

Reply to rinky

6

newby101, on Feb 5, 2009 9:35:45 am GMT
  • +1

Would similar scripting work for local worstations whereby the objective is to extract logon logoff information from a csv or bat file?

Let us say that you have user1 user 2 and user3 (registered in Windows environment)
Extracting their logon/logoff sessions seems to cause several issues when the goal is to eliminate other useless info from windows generated log events:

Looking for output in the format:

User: T1 Computer: C1 Date: 02/14/2009 Logon: 9:00 Logoff: 14:00
...
User: Tn Computer: Cn Date: 02/16/2009 Logon: 11:00 Logoff: 18:00

Reply to newby101

9

 sattu, on Apr 29, 2009 8:00:27 am BST

Hi please give me the script

Reply to sattu