Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
DOS/PDA/Other
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor recovery registry cleaner router screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Writing command line outputs to local files

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
ajetrumpet's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
Experience: Intermediate
01-Nov-2009, 01:16 AM #1
Writing command line outputs to local files
hello all,

I have asked this on a couple of forums, but I thought I would check here too. I can write the following to output the DOS list of files and folders of the current directory to a text file:
Code:
dir /b > dirs.txt
this works beautifully when I'm in CMD.EXE mode, but not in FTP mode. Does anyone know if the same thing is possible in FTP mode? when I write this same thing in that mode, I get this message:
Code:
USAGE: remote directory local file.
can anyone help me out with this one. thanks!
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,490 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
01-Nov-2009, 05:59 AM #2
Welcome to TSG!

I'm assuming you are wanting to capture a listing of the folder on the FTP server, not a local folder.

Would be nice if the USAGE: message would include an example or two, and showed what was optional.
It is just as the usage says, and is almost the same as in the command prompt.
In the command prompt, the usage is:
Dir [switches] [path] > file
You're using
Dir /B >dirs.txt
You aren't specifying a path, so the local folder is assumed.
In FTP it's the same minus the redirection symbol >:
remote directory=path
local file=file
But the switches are different. In an FTP shell, it's more or less a Unix shell, and Dir is an alias for ls, so google man ls to get the Manual page for the ls command. Note that some options may not be the same with your particular FTP server.
Here's just one:http://ss64.com/bash/ls.html

So for a bare listing saved to the local file dirs.txt, use this:
Dir [switches] [remote directory] [local file]
DIR -C1 dirs.txt

The switch means display in Columns (3 names per line) and the 1 changes that to one file per line (that is a one, not a lowercase L).
The C must be capitalized. A lowercase c sorts by modified(changed) time.

HTH

Jerry
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?

Last edited by TheOutcaste : 01-Nov-2009 06:06 AM. Reason: corrected a spoonerism:)
ajetrumpet's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
Experience: Intermediate
01-Nov-2009, 01:28 PM #3
hey Jerry. how are you? thanks a lot for your reply. Your response got me to the point that I am at right now. if you don't mind I have another question for you...

I am capturing everything just perfectly, but there is a problem I can't get my head around. I have this code for example:
Code:
      Dim vPath As String
      Dim vFTPServ As String
      Dim fNum As Long
      
      vPath = "C:"
      vFTPServ = "www.domain.com"
      fNum = FreeFile()
      
      Open vPath & "\FtpComm.txt" For Output As #fNum
      Print #1, "USER myUN" ' your login
      Print #1, "pass" ' your password
      Print #1, "dir " & Me.namefield & " c:\test.txt"
      Print #1, "close"
      Print #1, "quit"
      Close
      
      Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ, vbHide
i am doing this everytime I want to view the contents of the TEST text file. my question is, is there a way that I can leave the FTP session open, and keep printing lines in the FTPCOMM file and keep executing DOS commands one at a time this way instead of opening and closing the connection each time? thanks!
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,490 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
02-Nov-2009, 04:55 AM #4
Once you start the FTP session, you can't add lines to the script file, so you would have to close then open another session.
You can leave out the quit command, and use the script to open the session, then send commands to the FTP window using the SendKeys command, but I don't know enough VB to tell you how to do it. Not sure if SendKeys will work with a hidden window though.

Most FTP servers will disconnect you after a period of inactivity, so you would need some sort of keep alive routine as well.
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
ajetrumpet's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
Experience: Intermediate
02-Nov-2009, 02:24 PM #5
thanks Jerry. I'll give it a try or try and figure out how to do it. I am doing seperate sessions right now, which is not a good thing because the updates on my local machine take about 5 seconds to complete, and my hourglass in VBA doesn't work when I'm doing this either. So....the user would not know when to move onto the next action, but i can't have it take that long, so I'll try. thanks again man!
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 10:50 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.