Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Batch - Call Cygwin to Execute TCL Expect Script
    primarykey
    data
    text
    <p>I'm attempting to use Cygwin from a Windows server to automate some commands that need to be run on a remote Linux server. To solve this issue I've built an expect script that runs within Cygwin to SSH to the Linux server and execute the appropriate commands.</p> <p>Now I'm trying to take that automation one step further by wrapping the execution of Cygwin with a batch script and schedule it via the Windows Task scheduler.</p> <p>I've tried the following to call Bash from my batch script:</p> <pre><code>c:\cygwin64\bin\bash C:\myscript.exp </code></pre> <p>This causes the script to throw an error when the TCL Expect language syntax appears.</p> <p>I've also tried the following to call Expect from my batch script:</p> <pre><code> c:\cygwin64\bin\expect C:\myscript.exp </code></pre> <p>This causes the script to throw an error when I try to spawn SSH</p> <p>Here is a snippet from my Expect script:</p> <pre><code>#!/usr/bin/expect proc doSomething {p1 p2} { expect "* information here:" send -- "$p1\r" } set server [lrange $argv 0 0] spawn ssh perfmet@$server # Additional commands below </code></pre> <p>Is there any way for me to get this solution working?</p> <p>Edit: </p> <p>Here are the error messages when I use the Bash executable to launch the script:</p> <pre><code>C:\scpbot_reset&gt;scpbot_reset.bat C:\cygwin64\home\myaccountr\scpbot_reset\reset_script: line 2: proc: command not fo und C:\cygwin64\home\myaccountr\scpbot_reset\reset_script: line 3: expect: command not found C:\cygwin64\home\myaccountr\scpbot_reset\reset_script: line 4: send: command not fo und </code></pre> <p>Here is the error message when I use the Expect executable to launch the script:</p> <pre><code>C:\scpbot_reset&gt;scpbot_reset.bat couldn't execute "ssh": no such file or directory while executing "spawn ssh perfmet@192.168.0.199" (file "C:\cygwin64\home\myaccountr\scpbot_reset\reset_script" line 14) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload