?
Solved

command line to upload with ncftp

Posted on 2016-11-02
5
Medium Priority
?
190 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 56

Assisted Solution

by:Bill Prew
Bill Prew earned 2000 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article will review the basic installation and configuration for Windows Software Update Services (WSUS) in a Windows 2012 R2 environment.  WSUS is a Microsoft tool that allows administrators to manage and control updates to be approved and ins…
I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
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.…
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…
Suggested Courses

764 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