Solved: NcFTP Running a Script

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

nickelodeon

Thread Starter
Joined
Nov 29, 2002
Messages
590
Hey,

I have a script in a text file I would like NcFTP to run but not sure how to do it? In ftp.exe its something like -s:filename.txt but there isn't such command that I know of in NcFTP.

Thanks
 

nickelodeon

Thread Starter
Joined
Nov 29, 2002
Messages
590
Sure did.

Doesn't say in there how to actually execute a script from a text file.
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
Based on the doc on the NcFTP site, it appears NcFTP is designed to be called from within a script vs it processing a response file, like other FTP clients.

So you would have a batch file on Windows or a shell script on *nix to call NcFTP to login to the FTP site and transfer whatever files you need to transfer in an unattended or "batch" manner.

If you're wanting to send files, use NcFTPPut and if you're wanting to download files, use NcFTPGet.

So, let's say you put the login information in a text file called "login.txt" like this:

Code:
host mysite.com
user myid
pass mypasswd
In your batch file or shell script, you would invoke NcFTP like this to send a file:

ncftpput -f login.txt /remote/destination/path/for/file {local file}

For example:

ncftpput -f login.txt www/images header-img.png

The above would login to the FTP site specified in login.txt and upload the file "header-img.png" in the current directory to the "www/images" directory on the FTP site.

Peace...
 

nickelodeon

Thread Starter
Joined
Nov 29, 2002
Messages
590
Ah ok.

What I wanted to do was create a script that downloads specific files from the website to the local disk (like a backup). I have the script written out and if I execute it line by line it works so what I wanted was to run a command from NcFTP to read from the text file and execute those commands.

So say I've named this file download.txt and it is saved C:/download.txt how would I create a batch file to execute this with NcFTP?
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
It would basically be a one line batch file:

ncftpget -u {userid} -p {password} ftp://{ftp.addr.ess} {\path\to\backup\directory} {/remote/file/} {/remote/file/}

Example:

ncftpget -u myid -p mypassword ftp://ftp.tomdkatrocks.com c:\backups\website /www/uploads /www/logs/this-log.txt

This should download ALL of the "uploads" directory and the "/www/logs/this-log.txt" file to the c:\backups\website directory.

If you wanted to store the login info separately, I would create a file like login.txt above and change the above command to:

ncftpget -f login.txt ftp://ftp.tomdkatrocks.com c:\backups\website /www/uploads /www/logs/this-log.txt

At least, this should get you started.

Peace...
 

nickelodeon

Thread Starter
Joined
Nov 29, 2002
Messages
590
I've just been doing a bit of playing around and wrote a batch file with the following:

ncftp -u user-p password ftp.domain.com.au
ncftp lcd c:\myobback\success
ncftp cd /myobback/456/
ncftp mget *.*
ncftp lcd c:\myobback\789
ncftp cd /myobback/789/
ncftp mget *.*
ncftp lcd c:\myobback\111
ncftp cd /myobback/111/
ncftp bin
ncftp mget *.*
ncftp quit

When I open it it logs me in fine but then doesn't continue with the lcd command. Do you know why?

Thanks!
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
I've just been doing a bit of playing around and wrote a batch file with the following:

ncftp -u user-p password ftp.domain.com.au
ncftp lcd c:\myobback\success
ncftp cd /myobback/456/
ncftp mget *.*
ncftp lcd c:\myobback\789
ncftp cd /myobback/789/
ncftp mget *.*
ncftp lcd c:\myobback\111
ncftp cd /myobback/111/
ncftp bin
ncftp mget *.*
ncftp quit

When I open it it logs me in fine but then doesn't continue with the lcd command. Do you know why?

Thanks!
Instead of that, try this:

ncftpget -u user -p password ftp.domain.com.au c:\myobback\success /myobback/456/
ncftpget -u user -p password ftp.domain.com.au c:\myobback\789 /myobback/789/
ncftpget -u user -p password ftp.domain.com.au c:\myobback\111 /myobback/111/

Based on the NcFTPGet doc, NcFTPGet will use binary transfers unless explicitly instructed to use ASCII transfers.

Based on the NcFTP doc, it appears the NcFTP program supports command line arguments to log you in to the remote server but that's it. The other commands need to be entered interactively. That's why the NcFTPPut, NcFTPGet, and other programs exist.

Peace...
 

nickelodeon

Thread Starter
Joined
Nov 29, 2002
Messages
590
hmm I ran that but came up with an error: I can only retrieve regular files. Any thoughts?
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
hmm I ran that but came up with an error: I can only retrieve regular files. Any thoughts?
Hmmm, based on the NcFTPGet docs, it appears the "-R" option would be needed:

You can retrieve an entire directory tree of files by using the -R flag. However, this will work only if the remote FTP server is a UNIX server, or emulates UNIX's list output. Example:

$ ncftpget -R ftp.ncftp.com /tmp /pub/ncftp

This would create a /tmp/ncftp hierarchy.
However, you probably don't want to remote directory structure recreated on your local system. So, maybe try appending an asterisk at the end of the current lines would do the trick?

Maybe try:

ncftpget -u user -p password ftp.domain.com.au c:\myobback\success /myobback/456/*.*
ncftpget -u user -p password ftp.domain.com.au c:\myobback\789 /myobback/789/*.*
ncftpget -u user -p password ftp.domain.com.au c:\myobback\111 /myobback/111/*.*

If not, try adding the "-R' option (per the docs and example in the docs) and see if that works. If that doesn't, contact them to find out what you'll need to do.

Peace...
 

nickelodeon

Thread Starter
Joined
Nov 29, 2002
Messages
590
You sir are a genius. Works perfect. Just added the *.* to the end of it thank you very much!
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
Naw, not a genius at all. :)

Glad things are working for you! Please mark this thread as "solved" if all is well. :)

Peace...
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top