Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > SecureCRT on the Mac

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 03-10-2020, 06:47 PM
jdurrett jdurrett is offline
Registered User
Join Date: Jul 2005
Location: Dallas, Texas
Posts: 58
Send a message via Yahoo to jdurrett
Read cmds from file send string

I used to do everything on Windows and wrote lengthy vbscripts. Now my employment has changed and I'm using a Mac with SecureCRT and trying to get a handle on python scripting. sigh

I would like to start with a simple script to read commands from a file and send to screen. Platform is unix that im executing against.

#$language = "python"
#$interface = "1.0"

# Description:

def Main():

szPrompt = "[root@cenx-fault-1 _data]#"
objTab = crt.GetScriptTab()
objTab.Screen.Synchronous = True

objTab.Screen.IgnoreEscape = True

# Opening file
file1 = open('cmds.txt', 'r')
count = 0

# Using for loop
print("Using for loop")
for line in file1:
count += 1
send_stuff = ("Line{}: {}".format(count, line.strip()))
crt.Screen.Send (send_stuff)
crt.Sleep (100)
# Closing files

# crt.Sleep (60000)


Appreciate your assistance. Tried searching thru forum posts but didnt find what I was looking for.

Just want to read a line, sleep short pause and send next line...the commands are going to be multiline for unix..so I wont see prompt till the carriage return is sent on the last line of the text file i'm reading.
Reply With Quote

macos , python , read file , send string

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 01:01 AM.