Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Aspect Recorder, Initiate file upload?

Status
Not open for further replies.

RainmanKC

IS-IT--Management
May 5, 2004
4
US
I'm trying to automate a process where I dialup, establish a telnet session, then upload files from a specific local directory using zmodem protocol and then log off.

I have little programming knowledge and no experience with Aspect. The Recorder captures what keystrokes I take, but does not capture when I select "send file..." and nagigate into the proper directory and select the file that I want to upload. How do I code this portion of the script when I edit it before compiling?

Thanks for your help!

RainmanKC
 
The script recorder only captures data that is sent and received, but no mouse or menu-based interactions. Below is an example that shows how to upload a file and then branch depending on if the upload was successful or not:

proc main
integer iStatus

sendfile ZMODEM "filename"
iStatus = $XFERSTATUS
while iStatus == 1
iStatus = $XFERSTATUS
endwhile
if iStatus == 2
;Transfer successful, continue with script execution
elseif iStatus == 3
;Transfer failed, perform error handling
endif
endproc

aspect@aspectscripting.com
 
Knob,

Thanks for your help. I'm including the following code that I'm using. I was able to use what you suggested and upload a specific file. What I'm trying to do seems to be beyond my limited knowledge and programming experience though. Rather than upload a static file, I need to be able to upload any file found in a specific directory. So if there are 5 files in the directory, I need to be able to upload them 1 by 1 and then change the extention from ".zip" to ".bak" after the file has been successfully uploaded. So I'm thinking that I need some type of for -while loop where I loop for a specific number of times until there are no more files left in the directory. Do you have any sample code that does this, or could you tell me some of the commands or syntax that I need to use. Your help is greatly appreciated!

proc main
integer iStatus
string sUPLDPath ;Path to upload files from
string sDNLDPath ;Path to download file to
string sUPLDFile ;File to upload
string sDNLDFile ;File to download
string SUPLDPathFile
string sStatusSuccess
string SStatusFail
string sConnection ;Connection Directory entry to dial

sUPLDPath = "C:\Inetpub\ftproot\uploads\envoy\"
sDNLDPath = "C:\Inetpub\ftproot\downloads\envoy\"
sUPLDFile = "*.zip"
sDNLDFile = ""
sUPLDPathFile = "C:\Inetpub\ftproot\uploads\envoy\3103.zip"
sStatusSuccess = "Sucessful ZModem Transfer"
sStatusFail = "Failed ZModem Transfer"
sConnection = "Envoy-NEIC"
transmit "Z^M"
waitfor "^Begin file transfer procedure"

chdir sUPLDPath
sendfile ZMODEM sUPLDPathFile
usermsg "%s" sUPLDPathFile
iStatus = $XFERSTATUS
while iStatus == 1
yield
iStatus = $XFERSTATUS
endwhile
if iStatus == 2
;Transfer successful, Continue with script execution
usermsg "%s" sStatusSuccess
elseif iStatus == 3
;Transfer failed, perform error handling
usermsg "%s" sStatusFail
endif
waitfor "^Session Log (Y/N)"
transmit "N^M"
transmit "G^M"
endproc
 
You can use the findfirst/findnext commands to loop through all files in a specified directory. If you look at the discussion of the findnext command in the ASPECT help file, it includes an example script that should show you how to use that command.

As for renaming the file, you will likely want to use some of the system variables that are set by the findfirst and findnext commands. These system variables contain various parts of the filename (path, base filename, extension, etc.), and you could use them with the strcat command to "build" a new filename to rename the uploaded file to. If you look at the bottom of the findnext command discussion, the various system variables it modifies are listed (they start with a dollar sign).


aspect@aspectscripting.com
 
Knob,

Thanks again. I'm off the help file for findfirst, findnext, and strcat commands. This is what I needed.

RainmanKC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top