Solved

command line to upload with ncftp

Posted on 2016-11-02
5
44 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 53

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
What to do when Windows Update is not working correctly? What tools can I use to detect the cause of the malfunction problem? What does this numeric error code mean? These and other questions that you have been asking in the past are answered here (…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

809 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