Solved

command line to upload with ncftp

Posted on 2016-11-02
5
16 Views
Last Modified: 2016-11-22
I can successfully upload with ncftpput.exe, via:
ncftpput.exe -u "user" -p "pass" "ftp.domain.com"  "/access_db/" "c:\lock folder\lock.txt"

Open in new window

but I need to upload multiple files and rename those files.
is it possible to use ncftpput.exe without creating multiple connections and/or change the filename on the ftp server?  Or is there an easier way with ncftp.exe
0
Comment
Question by:Knightsman
  • 3
5 Comments
 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 500 total points
ID: 41870685
Are all the files heading to the same directory on the destination FTP server?  If so, then the easiest way might be to rename them on the PC and then send them all up at once from a staging folder.  NCFTPPUT does not support renaming as far as I know, and NCFTP.EXE is not command line friendly.

If you really need more control you might want to consider a different FTP client that has better script / automation support.

~bp
0
 
LVL 7

Accepted Solution

by:
Knightsman earned 0 total points
ID: 41891535
Want to finish up this question for those that need it.
I ended up going with WinSCP

Transfer file:
"put ""c:\Program Files (x86)\Common Files\folder\lock.txt"" /access_db/ " ^

Open in new window


Delete file:
"rm /access_db/lock.txt" ^

Open in new window


Rename file:
 "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register2.mdb" ^

Open in new window


This is the full code, you will need to use WinSCP.com instead of the .exe for batch files.
@echo off
"C:\Program Files (x86)\Common Files\folder\WinSCP.com" ^
  /log="WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://username:password@ftp.domain.com/" ^
    "put ""c:\Program Files (x86)\Common Files\folder\lock.txt"" /access_db/ " ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register.mdb" ^
    "rm /access_db/lock.txt" ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register2.mdb" ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register3.mdb" ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register4.mdb" ^

    "exit"
	

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%

Open in new window

1
 
LVL 7

Author Comment

by:Knightsman
ID: 41892126
updated
0
 
LVL 7

Author Closing Comment

by:Knightsman
ID: 41897220
Wanted points to go to Bill for the idea to switch Programs.  But wasn't file solution, wasn't sure how to finalize.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Resolve DNS query failed errors for Exchange
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now