?
Solved

Sending a command to a host session and I need to copy the response as a .txt file.

Posted on 2008-09-30
4
Medium Priority
?
400 Views
Last Modified: 2012-05-05
I am using a macro to send a command to an Attachmate session.
I now need to capture the response of the command to a .txt file or excel, and save it automatically, replacing the existing file with the new.

Once working this process would need to be done nightly, but I assume I can use scheduler or other method.

I tried to record the macro using Capture Incoming Data but that does not work as the macro doesn't actually pick that up. Any ideas?
0
Comment
Question by:vzdog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:vzdog
ID: 22620116
any ideas anyone?
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 22648008
how do you send the command ?
Shell.Execute , WSH.run ?

this will determine how the response is being received by the client and may allow some insight in how to capture.

0
 

Author Comment

by:vzdog
ID: 22650596
This is the code I am using send send the commands.
Right now as you can see it was built to only "copy" from Excel and "paste" in to the Attacmate session with no concern from capturing the response back.

I now need to capture the hosts response and record it back on to the same Excel sheet, i another column ie; "C" so it stays associated to the command sent.

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
 
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
	Dim Sessions As Object
	Dim System As Object
	Set System = CreateObject("EXTRA.System")	' Gets the system object
	If (System is Nothing) Then
		Msgbox "Could not create the EXTRA System object.  Stopping macro playback."
		STOP
	End If
	Set Sessions = System.Sessions
 
	If (Sessions is Nothing) Then
		Msgbox "Could not create the Sessions collection object.  Stopping macro playback."
		STOP
	End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
    g_HostSettleTime = 3000        ' milliseconds
 
    OldSystemTimeout& = System.TimeoutValue
    If (g_HostSettleTime > OldSystemTimeout) Then
        System.TimeoutValue = g_HostSettleTime
    End If
 
' Get the necessary Session Object
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    If (Sess0 is Nothing) Then
        Msgbox "Could not create the Session object.  Stopping macro playback."
        STOP
    End If
    If Not Sess0.Visible Then Sess0.Visible = TRUE
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    
'--------------------------------------------------------------------------------
'Declare the Excel Object
        Dim xlApp As Object, xlSheet As Object, MyRange As Object
        Set xlApp = CreateObject("excel.application")
        xlApp.Application.DisplayAlerts = False 'Turn off Warning Messages'
        xlApp.Visible = True
        xlApp.Workbooks.Open FileName:="D:\PMDaily\Fetch.xls"
        Set xlSheet = xlApp.activesheet
        Set MyRange = xlApp.activesheet.Range("A:A")
  
 
Dim Row As Long
        With xlApp.ActiveSheet
           Set MyRange = .Range("A2:A65536").Resize(xlApp.CountA(.Range("A2:A65536")))
        End With
        For Row = 1 To MyRange.Rows.Count
           Sess0.Screen.PutString MyRange.Rows(Row).Value, 24, 6
           Sess0.Screen.SendKeys "<ENTER>"
           Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        Next Row
 
End Sub
 
Open in New Window Select All 

Open in new window

0
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 2000 total points
ID: 22654443
sorry I know nothing of the attachemate object.

but http://www.tek-tips.com/viewthread.cfm?qid=1450207&page=4 shows example
Sess.Screen.getString(10, 7, 5).Value = Trim(aSheet.Cells(i, "c"))

which would indicate you can retrieve values in the same way eg.
myVal = Sess.Screen.getString(10, 7, 5).Value

need to checkuo the syntax of the Sess.Screen object model.


http://www.tek-tips.com/faqs.cfm?fid=4069 may help with object model. Note that this means doing development within Excel VBA and then porting to VBS as VBS cant define variables as a particular object.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This video shows how use content aware, what it’s used for, and when to use it over other tools.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question