![]() One of these examples and what I've given you should get you there, or at least in the ballpark. There are many examples on the 'net on how to do an expect script to log on to a server and issue commands. The expect script will capture that variable asĪnd you reference it in the script as $hostipornameįor example, you woudl probably have a line like this: SecureCRT l phn mm cung cp cho ngi dng nhng tnh nng v la chn hon ho cho vic bo mt cc d liu quan trng trn my tnh c nhn, h tr truy cp an ton t xa, truyn tp tin v d liu qua mt ng truyn chng r r thng tin n ngi nhn. ![]() expectscriptname.exp $ around the name is not necessary, but good form. The Logon Actions category of the Session Options dialog allows you to run scripts to automate logging on to a remote machine and perform other functions. A for loop will do that:įor hostiporname in `cat *.txt | grep -v "^\#"`įor hostiporname in `cat *.txt | grep -v "^\#"` do. So you need a command to get non-comment lines from your *.txt files, then pass that as a parameter to your expect script. I made an xx.txt that looks like this (I always use comments) This will take two scripts, or an expect script and a shell command. To make this work you have to create a separate login script for each device and save. I don't do VB, but I think I understand where this is going - you get a list of IP addresses or server names from all the *.txt files in a directory, then "do the expect stuff" against those. Dont worry all the scripts are in a zip file at the bottom of the post. Set file = fso.OpenTextFile(ObjFSO.FileName, ForReading, False)Ĭrt.Screen.WaitForString "Enter Form Name (or ?): "Ĭrt.Screen.WaitForString "Enter Command I=Insert R=Review U=Update D=Delete: ", 60Ĭrt.Screen.WaitForString "Enter Form Name (or ?): ", 60Ĭrt.Screen.Send "grep rtr /etc/hosts" & vbCrĬrt.Screen.Send "ssh " & str & vbCrĬrt.Screen.Send "password" & vbCr '#Manually enter password here.Ĭrt.Screen.Send "cp authorized_keys authorized_keys_bkup" & vbCrĬrt.Screen.Send "cat /app2/.ssh/Vkey > authorized_keys" & vbCrĬrt.Screen.Send "cp Vkey Vkey.orig" & vbCrĬrt.Screen.Send "cat Vkey > authorized_keys" & vbCrĬrt.Screen.Send "rm /app2/.ssh/Vkey" & vbCr Set fso = CreateObject("Scripting.FileSystemObject") ObjFSO.Filter = "Text Files|*.txt|All Files|*.*" Set ObjFSO = CreateObject("UserAccounts.CommonDialog") See the Scripting / Script Objects Reference topic in SecureCRT's Help file for more info.SDir = "D:\Documents and Settings\BIRDBOYEE" StrPathVar = "parsed result from "Ĭrt.Screen.WaitForString "MyJumpHostPrompt" Then it would be a simple matter of using Send() to run the command once verifying you were at the shell of the jump host: ![]() You can use the Path property available to the Session Object to get the session name (but then you would need to parse out any extraneous info if this session happens to be nested inside folders). If you would rather not use dependent session, it's probably a simple enough script as you would just be sending a command once you authenticate successfully to the jump host. In SecureCRT, the message is displayed in a pop-up message box with a varietyof buttons, depending on which options are chosen. See this YouTube video about using Dependent Session to connect via a jump host. Securecrt Ssh Login Script Login Ssh Login Command messagebox(message, title', options0) Prints a message for the user. Added support for dependent sessions so that a connection can be made to a jump host or SSH gateway before the session is connected.If your jump host is capable of port forwarding, I would think this method of going through a jump host would be simpler:Ĭhanges in SecureCRT 7.1 (Beta 1) - February 26, 2013 Example Python Scripts for SecureCRT ® for Windows and Mac. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |