Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Secure Shell

Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2006, 02:28 PM
dkonda dkonda is offline
Registered User
 
Join Date: Dec 2006
Posts: 3
Invoking SecureCRT from a batch/script?

Hi,

Is there a way to run a set of DOS-style commands that would:

- start SecureCRT & connect to a remote server via SSH
- run 2 specific commands on the remote server
- exit

I'm trying to see if the above can be done without starting SecureCRT in the traditional GUI mode & then connecting to remote servers using either stored profiles or quick connect mode.

Has anyone done this before? The utopia would be to have a DOS .bat file/script that would accomplish this.

Relevant info: SecureCRT v4.1.4 running on Windows XP Professional.

Any input would be appreciated. Thanks
Reply With Quote
  #2  
Old 12-21-2006, 06:47 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 819
Hello dkonda.

You can launch SecureCRT from dos in a minimized fashion
with a command like this:

start /min SecureCRT

You can also specify a logon script that you want to run
when SecureCRT launches using the /Script flag like this:

start /min SecureCRT /script "C:\temp\myautomationscript.vbs"

The script can automate some tasks like the following sample
script on our website:

http://www.vandyke.com/support/crt/s...t_ssh2_vbs.txt

If you end the script with crt.quit, SecureCRT will close
when the script finishes.

Does that sound like what you are looking for?

Thank you

JJH
Reply With Quote
  #3  
Old 01-03-2007, 12:25 PM
dkonda dkonda is offline
Registered User
 
Join Date: Dec 2006
Posts: 3
Hi JJH,

Thanks for your great response. I followed your instructions & was able to get 99% of the way there. I have one last question:

DOS script reads:

start SecureCRT /script "ssh.vbs"

SSH script ssh.vbs is as follows:

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

' Connect to an SSH server using the SSH2 protocol. Specify the
' username and password and hostname on the command line as well as
' some SSH2 protocol specific options.

Sub Main

Dim host
host = "172.16.72.104"
Dim user
user = "user"
Dim passwd
passwd = "password"

cmd = "/SSH2 /L " & user & " /PASSWORD " & passwd & " /C 3DES /M MD5 " & host

crt.Session.Connect cmd

crt.Screen.Send( "net stop msftpsvc" & vbCR )

crt.Screen.WaitForString( "successfully." )

crt.Screen.Send( "net start msftpsvc" & vbCR )

crt.Screen.WaitForString( "successfully." )

crt.Screen.Send ( "exit" & vbCR )

crt.quit

End Sub

When the script reaches the last crt.quit command, instead of exiting SecureCRT, I get a dialog box that asks:

"Do you wish to disconnect from 172.16.72.104?"

"Yes" "No"

I have to manually click Yes to exit. Is there a way around this? Thanks
Reply With Quote
  #4  
Old 01-03-2007, 01:31 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 819
Hi dkonda

If you look in the General category of your Global Options,
you should see the "Show confirm disconnect dialog" setting.

If you disable that setting does the popup go away?

Thanks

JJH
Reply With Quote
  #5  
Old 01-03-2007, 02:37 PM
dkonda dkonda is offline
Registered User
 
Join Date: Dec 2006
Posts: 3
That did the trick!

Thanks JJH. Your help was invaluable.
Reply With Quote
  #6  
Old 01-03-2007, 02:48 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 819
Hi dkonda

Thanks for letting me know. I'm glad that helped.

JJH
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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