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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getfile xmodem to specific folder 1

Status
Not open for further replies.

y2kr

IS-IT--Management
Jun 21, 2005
6
US
Hi

I hope some one can help me with this. I have this script file to connect to a place, upload files and download files, but the download files I want them sent to specific folder. This is the script file:


#Define DownloadPath "f:\mp\download2"
#Define UploadPath "f:\mp\upload2"

proc main
integer iRetries = 5 ;Set number of redial attempts
integer iStatus ;Variable used for file transfers
integer iDay, iMonth, iYear, iHour, iMin, iSec
string sFileName
string sUpLoad = "f:\mp\upload2"
String sDownload = "f:\mp\download2" ;File to upload selected by user

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sFileName "%02d%02d%02d%02d" iMonth iDay iHour iSec
strcat sFileName ".997"



set terminal linewrap on


while 1
connectmanual DATA "xxxxxxxxxxx" ;Dial number
while $DIALING ;Pause while dialing
yield
endwhile
statmsg "%d" iRetries
if waitfor "+++" 5 ;If +++ string received
exitwhile
else
iRetries-- ;Decrement retries counter
if iRetries == 0 ;If five dial attempts have been attempted
errormsg "Could not establish connection - program aborting"
pwexit ;Close script and Procomm
endif
endif
endwhile

sendfile XMODEM "f:\mp\upload2\LOGON2"
iStatus = $XFERSTATUS
while iStatus == 1 ;Pause while transfer is ongoing
yield
iStatus = $XFERSTATUS
endwhile
if iStatus == 2 ;If transfer successful
;
elseif iStatus == 3 ;If transfer failed
errormsg "Could not send sign on - transmission aborting"
pwexit
endif

if isfile "f:\MP\upload2\OBTAIN.997" ;If SUBMIT file exists
sendfile XMODEM "f:\MP\upload2\OBTAIN.997"
iStatus = $XFERSTATUS
while iStatus == 1
yield
iStatus = $XFERSTATUS
endwhile
pause 5
chdir sDownload
getfile XMODEM "f\mp\download2\" sFileName
iStatus = $XFERSTATUS
while iStatus == 1
yield
iStatus = $XFERSTATUS
endwhile
if iStatus = 2
end()
else
errormsg "Could not receive file. - Transmission Aborting"
pwexit
endif
elseif iStatus == 3
errormsg "Could not send claim file medicare.emc - transmission aborting"
pwexit
endif
endproc

proc end
integer iStatus
integer iDay, iMonth, iYear, iHour, iMin, iSec
string sFileName
string sUpLoad = "f:\mp\upload2"
String sDownload = "f:\mp\download2" ;File to upload selected by user
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sFileName "%02d%02d%02d%02d" iMonth iDay iHour iSec
strcat sFileName ".MSG"

sendfile XMODEM "f:\MP\upload2\LOGOFF"
iStatus = $XFERSTATUS
while iStatus == 1
yield
iStatus = $XFERSTATUS
endwhile
pause 2
chdir sDownload
getfile XMODEM sFileName
iStatus = $XFERSTATUS
while iStatus == 1
yield
iStatus = $XFERSTATUS
endwhile
disconnect
pwexit
endproc
 
I assume you are referring to this line:

getfile XMODEM "f\mp\download2\" sFileName

If so, then what you need to do is either use the set dnldpath command to set the download path so the file is downloaded there, or you can use a second string variable and strfmt to create a string variable that contains both the download path and the name of the file, then use that string variable in the getfile command.


 
Hi Knob

Let me tell you you are the man. This work perfect. The only problem I had was I place de line in wrong place and was givin lots of error when compile. But I got to tell you thanks a lot.

Miguel
 
Hi,

I was able to use the info in here to create a script to download some files I need to get off a server so thanks a lot. One question though on the date and timestamp. This line:

strfmt sFileName "%02d%02d%02d%02d" iMonth iDay iHour iSec

How would I make this show me the month, day and year like this:

11032005 or 110305

instead?

Thanks In Advance
 
The below script would give you a date format of MMDDYYYY. To get MMDDYY, you would add this line after the strfmt command to get rid of "20" from the year:

strdelete sFileName 4 2

proc main
integer iDay, iMonth, iYear, iHour, iMin, iSec
string sFileName

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec

strfmt sFileName %02d%02d"%d" iMonth iDay iYear
endproc

 
Wow! I'm a dork. It makes perfect sense, all the info was there. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top