JEMTHA Posted January 21, 2016 Share Posted January 21, 2016 Hi everyone i'm trying to inject some commands throught Comspec but it's not working. Here's what I do: Run(@ComSpec & ' /c Echo | Y '&$resources&'PLINK.EXE -ssh '&$s_SWNumber&' -l '&$s_TechGID&' -pw '&$s_TechPWD&' sh int status > '&$temp&'status_'&$s_SWNumber&'.txt', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) I absolutely need the Echo | Y thing to acknowledge the switch private key i'm connecting to. If i do so with the /k switch and without the @SW_HIDE, i got this: I'm kind of stuck and don't know how to achieve this. (Sry if this a dumb question, I'm fairely new to Autoit ) Thanks Link to comment Share on other sites More sharing options...
JEMTHA Posted January 21, 2016 Author Share Posted January 21, 2016 Hi again. Sorry to push but if someone could help, that would help me a lot. Thanks. Link to comment Share on other sites More sharing options...
jguinch Posted January 21, 2016 Share Posted January 21, 2016 What is Echo |Y supposed to do ? It's not relative to AutoIt, you cannot execute that in a command prompt Run(@ComSpec & ' /k Echo | Y') JEMTHA 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
JEMTHA Posted January 21, 2016 Author Share Posted January 21, 2016 6 minutes ago, jguinch said: What is Echo |Y supposed to do ? This is supposed to accept a secret key given by a switch. you can answer Yes or No. Doing this right from a cmd prompt is working. E.g.: Echo | Y PLINK.EXE -ssh SWITCHNAME -l MYLOGIN -pw MYPWD sh int status > OUTPUT.txt The code above is working, I can accept the key and get my output. Link to comment Share on other sites More sharing options...
jguinch Posted January 21, 2016 Share Posted January 21, 2016 Sorry, I don't understand how it can work. Maybe someone else ? JEMTHA 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
iamtheky Posted January 21, 2016 Share Posted January 21, 2016 (edited) I dont see how that would work either. In practice I would connect to that with putty, save that session. And then call that session from Plink. Quote If you have already set up a PuTTY saved session, then instead of supplying a host name, you can give the saved session name. This allows you to use public-key authentication, specify a user name, and use most of the other features of PuTTY: Z:\sysosd>plink my-ssh-session Sent username "fred" Authenticating with public key "fred@winbox" Last login: Thu Dec 6 19:25:33 2001 from :0.0 fred@flunky:~$ (You can also use the -load command-line option to load a saved session; see section 3.8.3.1. If you use -load, the saved session exists, and it specifies a hostname, you cannot also specify a host or user@host argument - it will be treated as part of the remote command.) http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter7.html Quote ^^ bonus quote I cant get rid of Edited January 21, 2016 by iamtheky JEMTHA 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
JEMTHA Posted January 21, 2016 Author Share Posted January 21, 2016 The thing is that we are working on switches located all over the world and many technician needs to connect to them. Unfortunately, our global network team does not have all switches fingerprints stored in a .reg file (which could have ease my work a lot ^^) To do so, I'm using plink, which is the command line version of putty and to accept any fingerprints, I have to accept the key. Message from a non-stored key is: Quote The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is: ssh-rsa 1024 cc:78:13:a3:68:a6:59:7e:b8:23:2d:13:3e:66:9b:b9 If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n) Connection abandoned. When opening a command prompt (cmd.exe), I type: Echo | Y PLINK.EXE -ssh SWITCHNAME -l MYLOGIN -pw MYPWD sh int status > OUTPUT.txt The key is accepted and I get my output. With autoit, when I write the @Comspec version of the code above: Run(@ComSpec & ' /c Echo | Y '&$resources&'PLINK.EXE -ssh '&$s_SWNumber&' -l '&$s_TechGID&' -pw '&$s_TechPWD&' sh int status > '&$temp&'status_'&$s_SWNumber&'.txt', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) This is not working. Question is, how to translate the cmd version to the @Comspec version? Is it clearer? 22 minutes ago, iamtheky said: I dont see how that would work either. In practice I would connect to that with putty, save that session. And then call that session from Plink. This will compromise all the automation process, and we'd loose time and efforts. I'm wondering if a .bat file won't be faster... Link to comment Share on other sites More sharing options...
iamtheky Posted January 22, 2016 Share Posted January 22, 2016 (edited) I cant get Y to work as the first thing after a pipe at all, for anything. tells me y is not recognized as a command. I think that is perhaps jgunich's issue as well Edited January 22, 2016 by iamtheky JEMTHA 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
PACaleala Posted January 22, 2016 Share Posted January 22, 2016 Part of the command line should be changed to "Echo Y | ...." to make sure that PLINK always gets the intended confirmation @" Store key in cache? (y/n) " JEMTHA 1 Link to comment Share on other sites More sharing options...
JEMTHA Posted January 22, 2016 Author Share Posted January 22, 2016 6 hours ago, PACaleala said: Part of the command line should be changed to "Echo Y | ...." to make sure that PLINK always gets the intended confirmation @" Store key in cache? (y/n) " That is perfect... I though I tried that before but I wrote so many thing that I'm not that sure. But, this is working! Plink is now getting the key! Thanks PACaleala, you're the man Link to comment Share on other sites More sharing options...
AutoBert Posted January 22, 2016 Share Posted January 22, 2016 (edited) You forget a space before plink.exe: Run(@ComSpec & ' /c Echo | Y '&$resources&'PLINK.EXE -ssh '&$s_SWNumber&' -l or is ´the last chr in resources a space ? Sorry, don't know how to delete this post Edited January 23, 2016 by AutoBert Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now