Page 1 of 2

script command plink.exe

Posted: 09 Dec 2016 10:09
by estebanfull
Hello, i tried to create a script with plink which it execute commands in a file .txt
It contains : start C:\Users\Administrateur\Desktop\plink.exe -ssh 10.1.1.1 -t -l admin -pw switch -m command.txt

the command.txt contains just "mkdir test"

start C:\Users\Administrateur\Desktop\plink.exe -ssh 10.1.1.1 -t -l admin -pw switch < command.txt doesn't work too

it result with an "FATAL Error"


with powershell there is this error :
plink.exe : FATAL ERROR: Server sent disconnect message
+ CategoryInfo : NotSpecified: (FATAL ERROR: Se...connect message:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

type 2 (protocol error):
"ssh + command not available"

can you please help me to fix it

Re: script command plink.exe

Posted: 11 Dec 2016 08:38
by tgn
plink doesn't use local command files. you can only start scripts, that are present in the remote file system.

regards...


--- back to basics... focus your eyes to the essential things... ---

Re: script command plink.exe

Posted: 12 Dec 2016 04:30
by estebanfull
Thanks to you for reply, I tried to run a .sh in /flash with "mkdir test" inside but it doesn't work. How can I start it please?
There is always the same error

Re: script command plink.exe

Posted: 12 Dec 2016 08:28
by tgn
have tried it with a ssh via plink to a linux system. and it works (even with the option -m for local commandfile > which i've never used before :) )...
Are you sure that "mkdir test" is possible via a "normal" ssh-session?

regards...


--- back to basics... focus your eyes to the essential things... ---

Re: script command plink.exe

Posted: 12 Dec 2016 08:32
by tgn
Also try plink without any options.

regards...


--- back to basics... focus your eyes to the essential things... ---

Re: script command plink.exe

Posted: 12 Dec 2016 08:40
by estebanfull
start C:\Users\Administrateur\Desktop\plink.exe -ssh 10.1.1.1 -t -l admin -pw switch
It works
"Welcome to the Alcatel-Lucent OmniSwitch 6000
Software Version 6.3.1.1052.R01 Service Release, December 11, 2008.

Copyright(c), 1994-2007 Alcatel-Lucent. All Rights reserved.

OmniSwitch(TM) is a trademark of Alcatel-Lucent registered
in the United States Patent and Trademark Office." appears

with "-m file.txt" or "< file.txt" or just a command after the password it doesn't works there is the same error
"mkdir test" works when I use putty and that I write it myself...

Regards

Re: script command plink.exe

Posted: 12 Dec 2016 09:59
by estebanfull
Please find attached the error that powershell and plink evoke

Regards

Re: script command plink.exe

Posted: 12 Dec 2016 14:15
by tgn
the server closes the connection because the execution of pure commands without a ssh-session is not supported.

maybe this example for a cisco switch will lead you to success -> https://zeleskitech.com/2014/08/02/send ... owershell/
it opens a ssh.session and sends the commands trough an input stream object.

i've found it with a simple google search. https://www.google.de/search?q=ssh+powe ... 8gfYkbq4Cw

if it works pelase share it :)

may the force be with you ;)

regards...

Re: script command plink.exe

Posted: 13 Dec 2016 08:30
by estebanfull
Hello, first of all thanks to you for your response and your involvement :) . I tried the solution that you have proposed and there are a number of errors. So I tried this solution from PowerShell Module and I noticed that the connection was apparently fine but there is no index associated with the connection (necessary when calling the command "Get-SSHSession"). I think this is not normal compared to what I found on internet, so I still do not know what to do.
You can find attached what I have done on PowerShell module..

Regards

Re: script command plink.exe

Posted: 14 Dec 2016 07:53
by estebanfull
So I updated PowerShell and I got a number for the SessionID but when I try to send a command it say me that the client is not connected and just before it say connected : true