-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Thom C. Blackwell
Sent: Tuesday, February 26, 2008 5:31 AM
To: [email protected]
Subject: RE: [Talk] Unix and Boston
Greetings,
There are likely easier ways of doing this than reading the output from a
command window. I know very little about UNIX, but I think you can mount a UNIX
file system so it shows up as a drive in Windows - no clue how you'd do such a
thing, just know I've seen it before. Once this was done, I'd suspect the
FileSystemObject could do stuff with the files (there are examples of using the
file system object on our website).
I'd suspect you could use FTP - there are examples using our built in FTP on
the site too.
But as an exercise (always good to practice to keep scripting skills sharp J) I
took a crack at do this using the console connection.
At first, the tricky piece appeared to be to reading the output of a DIR a
console - since that it can "scroll" if the list is bigger than the available
window. However, there is an option that the DIR command can accept - /p that
allows you to pause one screen at a time. So the script can read one page at a
time using a For / Next Loop. The next tricky piece is where to read. When you
first send the DIR command, the screen displays volume info etc on rows 1-5.
After you get another page however, the files show up in there rows, so I had
to take that into account.
Finally, need to know when you are at the end of the list.
And of course, the results will likely need to be parsed to get what you want
etc. I didn't go too far with this ...
As I said above, there's likely an easier way but the example code below seems
to do the trick - not a bad scripting exercise for first thing in the morning J
Here's my example:
Sub ReadDIR()
Dim fileList As New Collection
Dim directoryList As New Collection
Connect "cmd", stConsole
Pause "Microsoft [EMAIL PROTECTED],*"
Enter "dir /p"
Pause "Directory [EMAIL PROTECTED],*"
firstpage = True
ReadMore:
Wait
For i = 1 To 24 ' See where the files start this would be based on the Console
size settings
If firstpage Then ' he first page of files starts at row 6, any others start at
row 1
i = i + 5
firstpage = False
End If
temp = View(Row:=i, Col:=1, Length:=73)
'Here we detect "End of List"
If Trim(temp) = "" Then
'No more files
Exit For
End If
'Here store either files or directories
If InStr(temp, "<DIR>") Then
directoryList.Add Trim(temp)
Else
fileList.Add Trim(temp)
End If
Next i
At ""
If At("Press any key to continue") Then
Enter
GoTo ReadMore
End If
'Here close the console gracefully because I am done with it.
Connect "", stStream
For i = 1 To fileList.Count
Debug.Print fileList(i)
'Here's where you'd do parsing to get your file information
'For example, getting the date
fdate = Trim(StrLeft(fileList(i), 10))
If fdate = "" Then
'This must be the "count info" at the bottom of the list
End If
Next i
End Sub
Thom C. Blackwell
Product Manager
Boston Software Systems
(866) 653-5105 ex 807
www.bossoft.com <http://www.bossoft.com/>
Visit us in Booth 2471 at HIMSS08 - February 25-28 in Orlando, FL
Sign <http://www.bostonworkstation.com/customer_center/special_events.aspx> up
for my weekly webinar!
LEGAL NOTICE Unless expressly stated otherwise, this message is confidential
and may be privileged. It is intended for the addressee(s) only. Access to this
E-mail by anyone else is unauthorized. If you are not an addressee, any
disclosure or copying of the contents of this E-mail or any action taken (or
not taken) in reliance on it is unauthorized and may be unlawful. If you are
not an addressee, please inform the sender immediately, then delete this
message and empty from your trash.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chen, Scott C
Sent: Monday, February 25, 2008 7:12 PM
To: [email protected]
Subject: [Talk] Unix and Boston
Just curious as to whether anybody has used CMD Console to FTP to Unix and
search for files in the directories?
If so, can you provide some assistance to me. How did you retrieve the
results of your search since it is character based?
Thanks,
Scott
DISCLAIMER:
This message is intended for the sole use of the addressee, and may contain
information that is privileged, confidential and exempt from disclosure under
applicable law. If you are not the addressee you are hereby notified that you
may not use, copy, disclose, or distribute to anyone the message or any
information contained in the message. If you have received this message in
error, please immediately advise the sender by reply email and delete this
message.
DISCLAIMER:
This message is intended for the sole use of the addressee, and may contain
information that is privileged, confidential and exempt from disclosure under
applicable law. If you are not the addressee you are hereby notified that you
may not use, copy, disclose, or distribute to anyone the message or any
information contained in the message. If you have received this message in
error, please immediately advise the sender by reply email and delete this
message.