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!

Aspect script to receive ASCII files

Status
Not open for further replies.

lkavanagh

IS-IT--Management
Oct 22, 2002
3
IE
Hi,
I'm completely new to Aspect but I can program (or at least I could !!)and it looks very powerful.
I want a script that will sit waiting for a modem to ring, answer it, receive a text file (or files) and place them in a directory.
Upon receiving a disconnect from sender (or a timeout of say 3mins )the script should loop around and wait for another connection.

If someone could just give me something basic to point me in the right direction I would be eternally grateful.
I'm sure if I get a basic outline I could fine-tune myself.

Cheers
 
Here's a script that should get you most of the way there. I don't have a modem on this machine, so I can't test it but I think it should work mostly OK. You'll need to add some code around the error-checking of the Zmodem transfer (I have comments there at the moment to point out the area). The when quiet command will cause the line to be disconnected if no data is received for three minutes.

proc main
integer iStatus

set modem autoanswer PW
set modem acceptcall data ON

while 1
while $CARRIER
when quiet 180 call closedown

getfile Zmodem
while iStatus == 1
iStatus = $XFERSTATUS
endwhile
if iStatus == 2
;Transfer successful, continue with script execution
elseif iStatus == 3
;Transfer failed, perform error handling
endif
when clear
endwhile
endwhile
endproc

proc closedown
disconnect
endproc aspect@aspectscripting.com
 
Thanks a million - that gets me 90% there. Below is the script with a few changes I made. I have to use ASCII protocol as that's the way our users sent their articles.
A question - Is there anyway I can get procomm/Aspect to 'echo' back what it receives to the sender ??
I know I should be able to do this at modem level but I'm using internal modems and I can't seem to get them to echo back what they receive with AT commands.
Once again thanks - Larry

proc main
integer iStatus
integer cntr = 0
string FileIn = "c:\der\com3_"

set modem autoanswer PW
set modem acceptcall data ON

while 1
while $CARRIER
when quiet 180 call closedown
cntr = cntr +1
strfmt FileIn "c:\com3_%d" cntr
getfile ascii FileIn
while iStatus == 1
iStatus = $XFERSTATUS
endwhile
if iStatus == 2
termmsg "successful"
yield
;Transfer successful, continue with script execution
elseif iStatus == 3
termmsg "Un-successful"
;Transfer failed, perform error handling
endif
when clear
endwhile
endwhile
endproc

proc closedown
disconnect
endproc
 
One additional suggestion on your script - you may want to change the termmsg commands to transmit instead. Termmsg will just output the string to the Procomm window instead of sending it to the people calling the system.

As for echoing the text back to the user, that may be a little difficult since ASPECT is unable to access the incoming text during a file transfer.

You might also want to look into the host script that comes with Procomm. It probably does more than what you need, but it might handle the echoing situation you have.
aspect@aspectscripting.com
 
thanks - hope I'm not clogging this forum up ?
Another few questions (if ya have time) - I want to watch 2 internal modems - do I have to start procomm a second time and is it happy to run twice on one pc or am I better off getting another PC ?


below is the script as it stands now (when quiet was casuing memory errors !!). Seeing as Aspect hasn't access to the data as it's being received I tried to 'transmit' messages back to sender (in pace of echoing back text) but the 2nd transmit never works. - any ideas ??
Also getfile was funny when receiving to a network drice so I put it local and then copied up.
Feel free to alter script as required




proc main
while 1
statclear
rxflush
termreset
while $CARRIER
termreset
transmit "welcome please send your article"
cap()
endwhile
endwhile
endproc


proc cap
termwrites "In the cap procedure"
getfile ASCII "c:\der\com3_in"
transmit "thank you"
waitquiet 10 FOREVER
; transmit "thank you"
Disconnect
rxflush
copyfile "c:\DER\COM3_IN" "z:"
delfile "c:\DER\COM3_IN"
endproc
 
You would want to have a separate session of each Procomm running for each modem. The easiest way to do this is to use the set modem connection command in the script to set the modem that should be used (meaning you would have one separate script for each modem you were monitoring). The format of the set modem connection command is set modem connection "connection_name" where connection_name is the name of your modem exactly as it appears in Procomm.

Once you have a script for each modem, the best way to launch the scripts is to probably create two shortcuts to launch Procomm and the script associated with each modem. You probably already have a Procomm shortcut from the install on your desktop which you can use to create the shortcuts to launch Procomm and your scripts. Right click on the shortcut, select Properties, and click on the Shortcut tab. Put your cursor at the end of the Target field, add a space, then the name of your script including the .wax extension.

I think the reason that the second transmit command is not working is that it is being executed immediately after the getfile command. If you use the while $XFERSTATUS code I posted earlier, I believe that should take care of the problem.
aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top