Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-13-2018, 06:14 AM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
Ymodem Transfer Receive script

I am attempting to download a file using a scripted Ymodem transfer. The transfer works great when I manually setup to do the transfer, but when I try the script I only get errors.

I am running version 8.0.2 of SecureCRT on a 64 bit machine with Windows 7.

The script I am using for the transfer is:

crt.Screen.Synchronous = True
crt.Screen.Send vbCr
'verify remote device is connected
nResult = crt.Screen.WaitForString("=>", 5)

If nresult <> 0 Then
'setup remote device to send file
crt.screen.send "File Read CFG.TXT" & vbCrLF
'remote device is ready to send
nresult = crt.Screen.WaitForString("Ready to send file", 5) & vbCRLF

If nresult <> 0 then
crt.FileTransfer.ReceiveYmodem
End if
End if

When I run the script, I get:

=>
=>File Read CFG.TXT#000 Ready to send file
Transferring , errors 39...Press Ctrl+C to cancel.File

The errors just keep counting up and the file never gets transferred.



To manually do the file transfer, I perform the following:

1. Type "File Read CFG.TXT" and Enter
2. The remote device responds with "#000 Ready to Send File"
3. I then click on Transfer / Receive Ymodem
4. The ymodem transfer starts and takes a few seconds to complete:


=>File Read CFG.TXT#000 Ready to send file

Starting ymodem transfer. Press Ctrl+C to cancel.
Transferring CFG.TXT...
512 bytes 170 bytes/sec 00:00:03 0 Errors

#001 Transfer Complete



It seems like the script command to ReceiveYmodem isn't setting up SecureCRT properly to receive the file, or it's not doing the same thing as setting up to receive the file manually.

I'm not sure if I am missing something in the script setup for the transfer? Do you have any ideas?

Thank you.
Reply With Quote
  #2  
Old 02-13-2018, 09:37 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi jmfrance,

Have you tried displaying the second nresult in a MsgBox()?

I think your WaitForString() may be malformed. You are trying to wait for what you sent, correct?

Code:
nresult = crt.Screen.WaitForString("Ready to send file" & vbCRLF, 5)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 02-13-2018, 10:26 AM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
Hi Brenda,

I am waiting for the remote device to respond. When the text "Read File CFG.TXT" is sent, the remote devices responds with "#000 Ready to Send File". So I am just looking for the last part of that to continue.

nResult returns -1.

If I remove the "If nresult <> 0 then" line I still get the same result.


crt.Screen.Synchronous = True

crt.Screen.Send vbCr
nResult = crt.Screen.WaitForString("=>", 5)

If nresult <> 0 Then
crt.screen.send "File Read CFG.TXT" & vbCrLF
nresult = crt.Screen.WaitForString("Ready to send file", 5)
msgbox(nresult)

crt.FileTransfer.ReceiveYmodem
End if




Thanks,

Jeff
Reply With Quote
  #4  
Old 02-13-2018, 10:28 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi Jeff,

Also, vbCR is what simulates pressing Enter, so your second Send() should end with that (as the first did), not vbCrLF:

Code:
crt.screen.send "File Read CFG.TXT" & vbCr
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 02-13-2018, 10:41 AM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
Brenda,

I had tried it as "vbCr" but that gives an error message window saying:

SecureCRT "The handler is invalid"

and then on the screen I get an error (I think from the remote device) saying:

#200 Transfer Aborted - Transmission error

Also, the Receive Ymodem example in the SecureCRT help uses vbCRLF:

VBScript

Syntax

crt.FileTransfer.ReceiveYmodem

Example

crt.Screen.Send "sz --ymodem myfile.txt" & vbCRLF

crt.Screen.WaitForString "sz --ymodem myfile.txt" & vbCRLF

crt.FileTransfer.ReceiveYmodem


Thanks,

Jeff
Reply With Quote
  #6  
Old 02-13-2018, 11:29 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi Jeff,

Quote:
Also, the Receive Ymodem example in the SecureCRT help uses vbCRLF:
Haha! I did not know that was the very example included in the Help topic. It was wrong in a script in our internal repository and we fixed it there. It's wrong in the Help topic too, sorry!

The Send() should have vbcr, the WaitForString() should be vbcrlf.

Can you attach a screenshot of the error you get when you use vbcr?


If you look at the SendYmodem example in that same FileTransfer Object Help topic, there is also a stray "S", see below. I will ask our documenters to fix this in a future version of the Help file. (It's a full-time job policing documentation for typos. Thanks for the heads-up!)

Code:
crt.Screen.Send "rz --ymodem" & vbCRS
crt.FileTransfer.SendYmodem
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 02-13-2018, 01:43 PM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
No problem!

Here is the screen shot of the error message:

[IMG]c:\temp\error.bmp[/IMG]


And just to clarify, this is the script that I am running now:

crt.Screen.Synchronous = True

crt.Screen.Send vbCr
nResult = crt.Screen.WaitForString("=>", 5)

If nresult <> 0 Then
crt.screen.send "File Read CFG.TXT" & vbCr
nresult = crt.Screen.WaitForString("Ready to send file", 5) & vbCRLF
msgbox(nresult)

crt.FileTransfer.ReceiveYmodem
End if
Reply With Quote
  #8  
Old 02-13-2018, 01:54 PM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
The error message is attached to this post.
Attached Images
File Type: gif error.gif (34.7 KB, 237 views)
Reply With Quote
  #9  
Old 02-13-2018, 02:58 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi Jeff,

I get that error too with this line:

Code:
nresult = crt.Screen.WaitForString("Ready to send file", 5) & vbCRLF
But not with this line:

Code:
nresult = crt.Screen.WaitForString("Ready to send file" & vbCRLF, 5)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #10  
Old 02-14-2018, 06:02 AM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
Good morning Brenda,

That fixed the problem. I am able to download the files now. As a reference, here's the final code that worked:

crt.Screen.Synchronous = True

crt.Screen.Send vbCr
nResult = crt.Screen.WaitForString("=>", 5)

If nresult <> 0 Then
crt.screen.send "File Read CFG.TXT" & vbCr
nresult = crt.Screen.WaitForString("Ready to send file" & vbCRLF, 5)

crt.FileTransfer.ReceiveYmodem
End if

Thank you so much for your help!

I have one final question, do you know if there is a way to set the download folder for the X/Y/Z Modem transfers in script?

Thank you,

Jeff
Reply With Quote
  #11  
Old 02-14-2018, 08:23 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi Jeff,

I am glad to hear the issue is resolved.

Quote:
I have one final question, do you know if there is a way to set the download folder for the X/Y/Z Modem transfers in script?
Almost all session-level INI options are configurable via the SessionConfiguration object. Please see info about that object and its GetOption() and SetOption() methods in SecureCRT's Help Topic Scripting / Script Objects Reference.

Code:
Set objTab = crt.GetScriptTab
Set objConfig = objTab.Session.Config

strNewDir = "C:\NewDownloadDirectory"
 
' Update the Config object's download directory:
objConfig.SetOption "Download Directory V2", strNewDir
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #12  
Old 02-14-2018, 12:42 PM
jmfrance jmfrance is offline
Registered User
 
Join Date: Feb 2018
Posts: 7
Great...Thank you for all your help!

Jeff
Reply With Quote
  #13  
Old 02-14-2018, 01:19 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi Jeff,

You are quite welcome!
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:08 AM.