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!

What server am I connected to?

Status
Not open for further replies.

JianBean

Technical User
Oct 26, 2003
26
US
I am wondering if there is a way to tell what server, connection directory entry, etc. I am connected to...
I have several scripts that can be run at any time, but if Procomm is already connected to the correct server, it's pointless to reconnect again![tongue]

Any ideas? [idea]

-Bean
 
That is pretty much what I was looking for, but many times I have to connect manually to different servers which are not in the connection directory.
And I don't have control over whether or not they are in the connection directory! (they're not my computers/this is being designed for a office)

Any chance I might be able to do that? (using connectmanual)

Thank you for your response though! It was what I was looking for, just not quite all of what I was looking for!

-Bean
 
When you say you are connecting manually, are you doing all of the steps yourself, or is one of your scripts making the manual connection for you instead of using the Connection Directory? If the latter, then you could use a string variable to hold the name of the system you are connecting to, issue the connectmanual command with that string as one of the arguments, and then check the value of that string later on if necessary to determine what system you are connected to.

If you are indeed making the connections yourself, then there are a couple options I can think of. The first thing I can think of is having the script send the necessary commands to the Procomm window to get the text from the manual connect dialog. This sample script shows how to do this:

proc main
string sSystem

sendkey ALT 'A'
mspause 50
sendkey 'L'
mspause 50
sendkey CTRL 'C'
mspause 50
sendkey ALT 'C'
mspause 50
cliptostr sSystem
usermsg "Last system connected to was: %s" sSystem
endproc

Another choice is to have a script running constantly that looks for a login prompt or other unique text so that it can tell you have logged into a system. The script could then view subsequent lines of data on the screen (using the termgets or termread commands for example), then try to pick out the system name if it is displayed in a consistent manner across all of the systems, such as in the command prompt or somewhere after the login (message of the day, for example).


aspect@aspectscripting.com
 
Yes I am using the 'connectmanual' command to connect to the different servers. But that is a very well taken point, if you connect to a server, and set a global variable equal to the server you connected to, as I understand it, that variable would stay (unless changed of course!) until you exit Procomm, or am I remembering this incorrectly?...

But also on your commands to open the 'manual connect dialog', don't they only work when you're disconnected, so then you would have to disconnect, so that you could see where you were connected, and then have to reconnect again!?

Checking for identifying system marks is a very good idea, unfortunately we have so many different TELNET systems here, it would be more than a pain to find consistencies between them all, and some are so similar that they're almost impossible to tell apart, even for human eyes, let alone computer 'eyes'!

Thanks again Knob, and do you think that using the global variables like I mentioned would work? I don't have time to try it just yet, but maybe you know?!

-Bean
 
Yes, if you set a global variable, its value will persist until you modify it or shutdown Procomm.

The script I posted just opens the manual connect dialog, copies the machine name to the Windows clipboard, and then to a string. It then closes the dialog. This can all be done without losing the existing connection.


aspect@aspectscripting.com
 
My apologies! I can use the manual connect dialog box when I'm still connected!
However, it doesn't work when I have manually connected to a server (TELNET). Either through the manual connect dialog box or the 'connectmanual' command in ASPECT.

After I've manually connected to any server, the manual connect dialog box option is greyed out, until I disconnect. But if I connect to a server out of my connection directory, it does allow me to access the manual connect dialog box...

Is this possibly just an issue with my installation of Procomm?
 
No, I can reproduce it on my install of Procomm. I would think that a small bug myself.

The only other way I can think of to get the machine name is to send the appropriate command to the system you are connected to to request this information, then have your script parse and act upon that. uname will work for Unix I know. As long as all of your system are running the same "kind" of operating system, this may work.


aspect@aspectscripting.com
 
Thanks Knob! You've given me some great ideas!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top