Comments (4)
The current expect("PATTERN1","PATTERN2",...)
function can only return the number which pattern is matched
Is what you mean that you want to get the console output which is matched ?
If it is right, it is impossible now. However, I can expand the specification as your request .
For example, If you wrote the script as local rc,lines = expect2("PATTERN1","PATTERN2",...)
, you would get the console lines with the variable lines
. Can this feature satisfy your needs?
from expect.
Thank you for your quick response.
I try to connect automatically for OpenVPN. If session is terminated internal by myself or external by admin, I just got signal messages such as SIGTERM or SIGUSR1, etc. That time, expect process stays on suspended mode. However I want to it get terminated.
echo(true)
PID=spawn ([[C:\Program Files\OpenVPN\bin\openvpn.exe ]],etc...)
expect("Enter Auth Username:")while true do
send(arg[1])
send("\r")
expect("Enter Auth Password:")
send(arg[2])
send("\r")
expect("token Password:")
send(arg[3])
send("\r")
status=expect("Enter Auth Username:","SIGTERM","SIGUSR1")if (status == 1 or status == 2) then
kill(PID)
break
end
endos.exit(1)
from expect.
At last!
I did it like this:
while true do
timeout=2592000
status=expect("Enter Auth Username:", "Enter Auth Password:", "token Password:", "SIGTERM")
if(status==0) then
sendln(arg[1])
end
if(status==1) then
sendln(arg[2])
end
if(status==2) then
sendln(arg[3])
end
if(status<0 or status==3) then
kill(PID)
break
end
end
In one way SIGTERM console output can be catched by expect method, exclusive other signals.
Other important issue is, expect is admitted as dangerous code for antivirus software. What can be done about this issue?
from expect.
Other important issue is, expect is admitted as dangerous code for antivirus software. What can be done about this issue?
I can do nothing for antivirus software behaviour .
from expect.
Related Issues (20)
- How to insert date/time into script? HOT 5
- Any other way of simulating the Enter key? HOT 10
- Help me ssh Auto input password with Expect HOT 4
- Redirect output? HOT 1
- Distribution via Chocolatey HOT 1
- issue using "scp" accept only single quoted arguments (instead of double quoted) HOT 1
- scp and ssh seems to impact earlier sendln commands HOT 5
- Please consider signing exe file so it can be used under Windows without complains HOT 2
- error message [syntax error] using example in Windows 10 HOT 6
- `The handle is invalid.` is output when using in GitHub Actions PowerShell. HOT 4
- How to pass batch variables to expect script? HOT 6
- how to suppress output lines works HOT 5
- Provide installers for package managers such as Scoop and Chocolatey HOT 3
- Capture output from program into LUA varaible? HOT 3
- Timeout seems does not work properly HOT 3
- How use another port in ssh? HOT 8
- Automatic logout happening? HOT 6
- what's the principle of this project? HOT 2
- Send Arrow Keys HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expect.