VKontakte.DJ
forum traveling
 

Celestial Software

...better by design

Home Support Scripting Home Script Examples VBScript example: ascii file send

VBScript example: ascii file send

E-mail Print

Here is a script implementation of a feature I get asked for a lot:  ASCII file send.  If you just want to take the contents of a file and send it to the remote host, this script is for you!  This is not a file transfer.  No SFTP or ZModem here. 

This is more like opening the file in a notepad, copying it to the clipboard, then pasting it into the terminal session.  The example opens a file "c:\sample.txt", then reads the contents and sends the entire thing to the host using AbsoluteTelnet's Terminal.SendText function.

 

Sub Main
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\\sample.txt")
If objFile.Size > 0 Then
Set objReadFile = objFSO.OpenTextFile("C:\\sample.txt", 1)
strContents = objReadFile.ReadAll
Terminal.SendText strContents
objReadFile.Close
Else
MsgBox "The file is empty."
End If
End Sub

It makes most sense to implement this as a user initiated script via the keyboard mapping function.  To do this, go to the Options->Properties->VTOptions page and do the following:

  1. Click the "edit keymap" button.
  2. On the key mapping dialog, click "add".
  3. You'll be prompted for a key combination to remap.  Click any key or key combination that you want to use to perform the script (F7 for example).  F7 will now be remapped.
  4. Now, you're prompted for the text to map F7 to.  In previous versions of Absolute, you could only enter a text string here to send to the host when F7 is pressed.  In Absolute 7, you can enter your script, but be sure to enter the first line as the text "VBSCRIPT"  This tells Absolute that the remainder of the text is a script to execute... (see below)
  5. Click Ok
  6. Click Ok
  7. Click OK

Back at the terminal screen, press F7 to send the file.  If the file cannot be found or it is empty, you should get error messages on the screen to help you determine the problem.  You can modify this script to change the location of the file or even to prompt the user for the name of the file!  This is a simple example to demonstrate the capabilites of AbsoluteTelnet scripting.  The rest is up to you!

VBSCRIPT
Sub Main
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\\sample.txt")
If objFile.Size > 0 Then
Set objReadFile = objFSO.OpenTextFile("C:\\sample.txt", 1)
strContents = objReadFile.ReadAll
Terminal.SendText strContents
objReadFile.Close
Else
MsgBox "The file is empty."
End If
End Sub

 

 

Related Links: VBScript API , Scripting Home

Last Updated on Friday, February 27, 2009 01:23 am  

Recent Forum Posts

info in Secure Shell by bpence, Oct 25, 2018 07:53 am
info in AbsoluteTelnet General by bpence, Sep 05, 2018 05:14 pm
info in Secure Shell by bpence, Jul 20, 2018 04:42 pm
info in Secure Shell by bpence, Jul 13, 2018 08:27 am
info in AbsoluteTelnet General by mod apk android, Sep 05, 2017 01:01 pm
I've tried lots of different telnet/ssh clients, and I have two long-time favorites: Putty and Absolute Telnet. Putty, because it's such a quick download that on someone else's machine i can run it without going through an install, and it runs ssh. But for my own machine, the only choice is Absolute Telnet. It stores my password, terminal appearance and connection settings so that it's literally 2 seconds from clicking the icon to being logged in to my remote ssh accounts. It's incredibly customizeable, but not overwhelmingly so. I hardly ever pay for software (I'm embarassed to say), but I like Absolute Telnet so much I've paid for the full version and I'm glad I did. It's important to note that this software is maintained by one guy, Brian Pence, who personally answers people's questions on his online forum and answers email inquiries (he's answered a couple of mine, and always been really helpful). I gotta say, you hardly ever get this kind of commitment and personal touch in software anymore. --Ben Wheeler