Coder Social home page Coder Social logo

loop condition for expect about expect HOT 4 CLOSED

hymkor avatar hymkor commented on June 11, 2024
loop condition for expect

from expect.

Comments (4)

hymkor avatar hymkor commented on June 11, 2024

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.

azizgokhannarin avatar azizgokhannarin commented on June 11, 2024

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
end

os.exit(1)

from expect.

azizgokhannarin avatar azizgokhannarin commented on June 11, 2024

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.

hymkor avatar hymkor commented on June 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.