View Full Version : print DOS outputs


ajetrumpet
10-31-2009, 07:43 PM
does anyone know if there is a way that I can print the output of a DOS command through VBA?

I have tried this:dir > dirs.txt

I am in the correct local directory and the file does exist. The problem is that it tells me that the file transfer is complete, but the text file always turns up empty. If there is a way I can get this in a text file, or even better, into the VBA window by the "debug.print" method, I would be greatful. thanks all!

georgedwilkinson
10-31-2009, 09:19 PM
Try doing a "DoEvents" before opening the file. Maybe put a pause in the Subroutine, too.

ajetrumpet
10-31-2009, 09:21 PM
Try doing a "DoEvents" before opening the file. Maybe put a pause in the Subroutine, too.george, did you understand what I was asking? I want to view the DOS window's text in the VBA window. How does a pause and a doEvents help? sorry, but I think I was unclear.

and also, I have since learned that this yields something of interest:DIR *.* /b > Dirs.txtwhen i type that in, I get this output, but I don't know what it means, but I think I'm close to getting what I want:Usage: dir remote directory local file

georgedwilkinson
10-31-2009, 09:33 PM
I'm not sure what you're doing.

ajetrumpet
10-31-2009, 09:34 PM
I'm not sure what you're doing.basically george, when I type DIR in the command line, I want to see the directory and file list in a local txt file on my computer instead of in the DOS window. does that make sense now?

George, the following works just fine in normal DOS mode (e.g. - CMD.EXE):dir *.* /b >dirs.txtthat writes the directory and all of it's contents to the text file, but what I want is for that same command to work in FTP mode. Do you know if this is possible?

georgedwilkinson
10-31-2009, 10:04 PM
You can output the entire ftp session to a file and use the ls (or in some ftps, dir) command to get a directory listing.

ajetrumpet
10-31-2009, 10:07 PM
You can output the entire ftp session to a file and use the ls (or in some ftps, dir) command to get a directory listing.

LS is a list command and I tried to manipulate that but couldn't figure out the command to output the list. LS on my vista machine only displays a list of files in the DOS window. Should I use the same command as I am now using with my local DOS process? Is that what you're saying?

I have just tried this george:ls > dir.txtit created a text file but didn't put anything in it. did I miss something?

mcclunyboy
11-05-2009, 04:00 AM
edited - sorry i just realised i have repeated what someone else typed.