Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How use another port in ssh? #32

Closed
9Demien9 opened this issue Dec 7, 2022 · 8 comments
Closed

How use another port in ssh? #32

9Demien9 opened this issue Dec 7, 2022 · 8 comments
Labels

Comments

@9Demien9
Copy link

9Demien9 commented Dec 7, 2022

Hello!
You did a great thing! Thanks.
I turn to your example.
But I can't use an alternative ssh port.
Perhaps you can give an example of how to do this. If you do not specify the port, everything works.

Thank you in advance!

@hymkor
Copy link
Owner

hymkor commented Dec 7, 2022

OK. I quoted the line calling ssh.exe from my Lua script.

local SSHEXEPATH=os.getenv("windir") .. [[\system32\OpenSSH\ssh.exe]]
local remoteid = arg[1]
spawnctx(SSHEXEPATH,
    "-o","ServerAliveInterval=60",
    "-N",
    "-v",
    "-o","PubkeyAcceptedKeyTypes=+ssh-dss",
    "-p","27311",
    "-L","13333:"..remoteip..":3389",
    "hymkor@example.com")

Can it satisfy your needs ?

@hymkor hymkor added the question label Dec 7, 2022
@9Demien9
Copy link
Author

9Demien9 commented Dec 7, 2022

spawnctx

How do you call expect directly from lua?

@hymkor
Copy link
Owner

hymkor commented Dec 7, 2022

spawnctx(NAME,ARG1,ARG2,...) is a new built-in function available since v0.5.0
It is similar with spawn() but the process started by spawnctx is killed automatically when Ctrl-C is pressed.

To specify the port for ssh.exe , would you set the parameter as below to spawn() or spawnctx() ?

"-p","27311",

@9Demien9
Copy link
Author

9Demien9 commented Dec 7, 2022

spawnctx(NAME,ARG1,ARG2,...) is a new built-in function available since v0.5.0 It is similar with spawn() but the process started by spawnctx is killed automatically when Ctrl-C is pressed.

To specify the port for ssh.exe , would you set the parameter as below to spawn() or spawnctx() ?

"-p","27311",

You don't quite understand me.
I am use expect as os.execute("expect.exe .....
How i can used expect directly in lua?
require "?"

@hymkor
Copy link
Owner

hymkor commented Dec 7, 2022

There are no ways to import Expect.Lua on the pure lua interpreter.

Expect.Lua is a standalone application using Gopher-Lua engine.
It is not a library.
spawn, spawnctx and other extended functions are available only in the script executed on expect.exe.

@9Demien9
Copy link
Author

9Demien9 commented Dec 7, 2022

There are no ways to import Expect.Lua on the pure lua interpreter.

Expect.Lua is a standalone application using Gopher-Lua engine. It is not a library. spawn, spawnctx and other extended functions are available only in the script executed on expect.exe.

Are you include expect.exe in lua?! But how?!

@hymkor
Copy link
Owner

hymkor commented Dec 7, 2022

The expect.exe contains the built-in Lua interpreter called as GopherLua that is the golang library.
You do not have to use require statement.
You have to make your script using spawn function and so on, and call it by expect.exe like expect.exe YOURSCRIPT.lua .

@9Demien9
Copy link
Author

9Demien9 commented Dec 8, 2022

Ожидаемый.exe содержит встроенный интерпретатор Lua, называемый GopherLua , который является библиотекой golang. Вам не нужно использовать requireоператор. Вы должны сделать свой скрипт, используя spawnфункцию и т. д., и вызвать его с помощью expect.exe, например expect.exe YOURSCRIPT.lua.

Yes, thanks a lot, I figured it out. I originally used io.popen in lua, but it only works with os.execute.

@hymkor hymkor closed this as completed Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants