Originally posted by AutomatedJim
View Post
Announcement
Collapse
No announcement yet.
HS3 Linux: Telnet Client via Script?
Collapse
X
-
Originally posted by zwolfpack View PostI'm not running HS on Linux - but I do know my UNIX So I'll volunteer this as a guess.
Save this shell script to a file on your rpi, call it something like telnet.sh
Code:#!/bin/sh # shell script to run a single telnet command USER=admin PASS=abc123 IPADDR=192.168.1.1 CMD="$*" (sleep 1; echo $USER; sleep 1; echo $PASS; sleep 1; echo "$CMD"; sleep 1; echo exit) | plink -batch -telnet $IPADDR
Code:$ chmod +x telnet.sh
Of course, this will run only one command. For multiple commands, repeat the same action with the different commands. (Perhaps with a short wait in between?) Or edit the script and hardcode the commands in sequence.
Thanks for the help. At first it would not run, searched about shell scripts and found I had to change:
Code:#!/bin/sh
Code:#!/bin/bash
Leave a comment:
-
I'm not running HS on Linux - but I do know my UNIX So I'll volunteer this as a guess.
Save this shell script to a file on your rpi, call it something like telnet.sh
Code:#!/bin/sh # shell script to run a single telnet command USER=admin PASS=abc123 IPADDR=192.168.1.1 CMD="$*" (sleep 1; echo $USER; sleep 1; echo $PASS; sleep 1; echo "$CMD"; sleep 1; echo exit) | plink -batch -telnet $IPADDR
Code:$ chmod +x telnet.sh
Of course, this will run only one command. For multiple commands, repeat the same action with the different commands. (Perhaps with a short wait in between?) Or edit the script and hardcode the commands in sequence.
Leave a comment:
-
Originally posted by zwolfpack View PostTelnet is a PITA to script. I couldn't get it to work with the telnet client, but as sparkman suggests, plink (PuTTY) is an option.
To install plink,
Code:$ sudo apt-get update $ sudo apt-get install putty-tools
Code:$ (sleep 1; echo user; sleep 1; echo password; sleep 1; echo "ls -al"; sleep 1; echo exit) | plink -batch -telnet 192.168.1.1
If this doesn't work for you, I found another working method that uses a python script. Give a holler if you want to take a look at that.
Originally posted by sparkman View Posthttps://en.wikipedia.org/wiki/Plink
You would run it as an external program from an event in HS. There's a version for the Pi.
Cheers
Al
Thanks for the help,
Jim
Leave a comment:
-
Telnet is a PITA to script. I couldn't get it to work with the telnet client, but as sparkman suggests, plink (PuTTY) is an option.
To install plink,
Code:$ sudo apt-get update $ sudo apt-get install putty-tools
Code:$ (sleep 1; echo user; sleep 1; echo password; sleep 1; echo "ls -al"; sleep 1; echo exit) | plink -batch -telnet 192.168.1.1
If this doesn't work for you, I found another working method that uses a python script. Give a holler if you want to take a look at that.
Leave a comment:
-
Originally posted by AutomatedJim View PostNot sure what that is or how it would integrate into HomeSeer.
Thanks,
Jim
You would run it as an external program from an event in HS. There's a version for the Pi.
Cheers
Al
Leave a comment:
-
I found this:
http://www.codeproject.com/Articles/...Telnet-library
In the introduction one of the options is "A program that executes scripts (scripted telnet)" which is what I want to do.
Have no idea how.
Thanks,
Jim
Leave a comment:
-
Originally posted by sparkman View PostHi Jim,
Take a look at plink.
Cheers
Al
Thanks,
Jim
Leave a comment:
-
HS3 Linux: Telnet Client via Script?
My goal is from HS3 RPi3 to run a telnet session to login to my network switch.
I have installed telnet on the RPi3 and from the CLI accomplish what I want.
I want to automated it on a schedule with Easytrigger and events to login to the switch, run a command, logout.
Any help would be appreciated. I am not a programmer.
Thanks,
JimTags: None
Leave a comment: