Solved

command line to upload with ncftp

Posted on 2016-11-02
5
118 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 55

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
Resolve DNS query failed errors for Exchange
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
In this Micro Tutorial viewers will learn how to restore their server from Bare Metal Backup image created with Windows Server Backup feature. As an example Windows 2012R2 is used.

707 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