Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-29-2018, 10:25 AM
mike1950r mike1950r is offline
Registered User
 
Join Date: May 2018
Posts: 5
Run Commandline Script

Hi,

I'm new here,
so hello to everybody.

I want to run a vbscript,
which runs securecrt,
which auto connects to the default server,
and then, when connected sends a command to the server:
"if /etc/init.d/dovecot status > /dev/null; then exit; fi"

If the dovecot server is running well,
securecrt gets an exit command and closes automaticly,
if dovecot server is not active,
securecrt stays active.

so if i ask the securecrt state in my starter vbscript,
i know, if dovecot server is running or not.

the goal is to run this in background without seeing the securecrt screen.

this is the logic.

my starter script begins:
Code:
strFile = C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe"
strCommand = strFile & " /SCRIPT " & "I:\IsDovecotServerUp.vbs"

objWshShell.Run strCommand, 0, True
It call the "isdovecotserverup.vbs" script well,
which contents:

Code:
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "if /etc/init.d/dovecot status > /dev/null; then exit; fi"
	crt.Screen.Send chr(13)
End Sub
but i get the error message:

CRT Scripting Runtime error

Error: Screen.Send not connected ... etc.

Normally when i start securecrt manually it automaticly connects the default server.

but not in this case.

this is my problem.

sorry 'bout my english,
which is not my mother language.

hope somebody can help me,

thanks in advance.

cheers mike

Last edited by jdev; 05-29-2018 at 12:36 PM. Reason: wrap code in [code] blocks
Reply With Quote
  #2  
Old 05-29-2018, 12:41 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 822
When you launch SecureCRT with the /Script command line argument, auto sessions do not get connected.

But, you can simply add an instruction to your command line to have SecureCRT connect to the session you desire. For instance, if your auto session's name is "My Auto Session Name", then your script can launch SecureCRT like this:

Code:
strFile = C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.exe"
strCommand = strFile & " /SCRIPT " & "I:\IsDovecotServerUp.vbs"
strCommand = strCommand & " /S " & chr(34) & "My Auto Session Name" & chr(34)

objWshShell.Run strCommand, 0, True
Note that I wrapped the 'My Auto Session Name' in chr(34) (double quote) statements in case your session name has spaces in it.
__________________
Jake Devenport
VanDyke Software
Technical Support
support@vandyke.com
http://www.vandyke.com/support
Reply With Quote
  #3  
Old 06-07-2018, 02:57 AM
mike1950r mike1950r is offline
Registered User
 
Join Date: May 2018
Posts: 5
thanks Jake,

works fine

cheers mike
Reply With Quote
Reply


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 05:11 PM.