Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

FTP batch command, please HELP


  • Please log in to reply

#1
Taran22

Taran22

    New Member

  • Member
  • Pip
  • 2 posts
So I am trying to put a log file on my FTP via batch commands. the command is as follows
:TOP
@echo off
title FTP
cd c:\
echo user username> ftpcmd.dat
echo password>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put c:\abc.log >> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat my.ftp.host.
del ftpcmd.dat
TIMEOUT /T 60
goto TOP

I am trying to put a file named "abc.log" located in c:\ to my ftp. now when I put this .bat file on desktop and run it , it creates a file named ftpcmd.dat (temporarily) in the same directory where my file "abc.log" is but when i place this .bat file in some other drive ( say D:\) and run it it creates ftpcmd.dat in D:\ drive itself and not in C:\ where my abc.log is.
PLEASE HELP it is required urgently for my college project

Edited by Taran22, 23 October 2013 - 02:35 AM.

  • 0

Advertisements


#2
SleepyDude

SleepyDude

    Trusted Helper

  • Malware Removal
  • 4,865 posts
Hi Taran :welcome:

Because you don't specify where the ftpcmd.dat is created the script creates the file on the current folder.
The safe way to do it is to use c:\ftpcmd.dat.

Now why it fails if running from D:?
Because you script relies on the CD command to set the working dir but when you use cd c:\ the shell changes the current location on C: to the root but don't change the actual drive! you need to use cd /d c:\ to also change the drive from D: to C:\

I hope my explanation is clear to you.

Edited by SleepyDude, 23 October 2013 - 04:41 AM.

  • 0

#3
Taran22

Taran22

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts

Hi Taran :welcome:

Because you don't specify where the ftpcmd.dat is created the script creates the file on the current folder.
The safe way to do it is to use c:\ftpcmd.dat.

Now why it fails if running from D:?
Because you script relies on the CD command to set the working dir but when you use cd c:\ the shell changes the current location on C: to the root but don't change the actual drive! you need to use cd /d c:\ to also change the drive from D: to C:\

I hope my explanation is clear to you.


Thank you very very much.. Omg this is the best & quickiest reply i've ever got. Thanks once again!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP