How to adjust this bash script to run telnet commands successfully while being in SSH?How do I parse command line arguments in Bash?How do I know the script file name in a Bash script?How to iterate over arguments in a Bash scriptHow to use SSH to run a shell script on a remote machine?How to check if a program exists from a Bash script?What is the cleanest way to ssh and run multiple commands in Bash?How to specify the private SSH-key to use when executing shell command on Git?How do I set a variable to the output of a command in Bash?Bash: Capture output of command run in backgroundHow to ssh and then telnet with ruby?

Which US defense organization would respond to an invasion like this?

Why do these characters still seem to be the same age after the events of Endgame?

Does expanded replace the romannumeral trick for expansion?

Is disk brake effectiveness mitigated by tyres losing traction under strong braking?

Where to draw the line between quantum mechanics theory and its interpretation(s)?

How can I get people to remember my character's gender?

Why symmetry transformations have to commute with Hamiltonian?

Nested loops to process groups of pictures

What to use instead of cling film to wrap pastry

Why didn't this character get a funeral at the end of Avengers: Endgame?

Can you use "едать" and "игрывать" in the present and future tenses?

Checking if two expressions are related

Why would a military not separate its forces into different branches?

It is as simple as ABC

Why did WWI include Japan?

Can I use a Cat5e cable with an RJ45 and Cat6 port?

Would you use "llamarse" for an animal's name?

Why do people keep telling me that I am a bad photographer?

What was Bran's plan to kill the Night King?

Is it normal for gliders not to have attitude indicators?

What is the closest airport to the center of the city it serves?

Are sleeping system R-ratings additive?

Out of scope work duties and resignation

Install LibreOffice-Writer Only not LibreOffice whole package



How to adjust this bash script to run telnet commands successfully while being in SSH?


How do I parse command line arguments in Bash?How do I know the script file name in a Bash script?How to iterate over arguments in a Bash scriptHow to use SSH to run a shell script on a remote machine?How to check if a program exists from a Bash script?What is the cleanest way to ssh and run multiple commands in Bash?How to specify the private SSH-key to use when executing shell command on Git?How do I set a variable to the output of a command in Bash?Bash: Capture output of command run in backgroundHow to ssh and then telnet with ruby?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am attempting to write a bash script that will do the following work flow:



  1. Telnet into networked device via IP address on port 9100 telnet x.x.x.x 9100

  2. Run SGD command ! U1 getvar "internal_wired.ip.timeout.value".

  3. Expect output value of "10".

Here is the bash script I've written so far:



#!/bin/bash

IP=(x.x.x.x)


for i in $IP
do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be `"10`". Let's get started!!"
echo " "
sleep 4
echo "5....."
sleep 1
echo "4...."
sleep 1
echo "3..."
sleep 1
echo "2.."
sleep 1
echo "1."
sleep 1
echo " "
telnet $i 9100 << END_SSH
sleep 5
getvar "internal_wired.ip.timeout.value"
sleep 5
END_SSH
done


When I run this script via bash mycode.sh, I get the following output in Terminal.app:



$ bash mycode.sh 

Welcome! This script will check the timeout value of this networked device.
The expected output should be "10". Let's get started!!

5.....
4....
3...
2..
1.

Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
Connection closed by foreign host.
[user@server ~]$


x.x.x.x is an IP placeholder just to add.



In theory, after the Escape character is '^]'. line, the script should have ran the ! U1 getvar "internal_wired.ip.timeout.value" command.



Also, we should have had an expected output of "10".



When I first wrote this script, I initially did not have the END_SSH command in it. A colleague introduced that to me and said to wrap the telnet commands in the END_SSH because of how Terminal technically jumps out of SSH when you are in telnet. I've tried utilizing END_SSH, but am not successful.



How do I get the telnet command to run successfully and get the expected output value?










share|improve this question






















  • Look into expect.

    – Shawn
    Mar 23 at 2:29






  • 1





    expect is a ridiculous overkill for that.

    – ExtraT
    Mar 23 at 3:49


















0















I am attempting to write a bash script that will do the following work flow:



  1. Telnet into networked device via IP address on port 9100 telnet x.x.x.x 9100

  2. Run SGD command ! U1 getvar "internal_wired.ip.timeout.value".

  3. Expect output value of "10".

Here is the bash script I've written so far:



#!/bin/bash

IP=(x.x.x.x)


for i in $IP
do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be `"10`". Let's get started!!"
echo " "
sleep 4
echo "5....."
sleep 1
echo "4...."
sleep 1
echo "3..."
sleep 1
echo "2.."
sleep 1
echo "1."
sleep 1
echo " "
telnet $i 9100 << END_SSH
sleep 5
getvar "internal_wired.ip.timeout.value"
sleep 5
END_SSH
done


When I run this script via bash mycode.sh, I get the following output in Terminal.app:



$ bash mycode.sh 

Welcome! This script will check the timeout value of this networked device.
The expected output should be "10". Let's get started!!

5.....
4....
3...
2..
1.

Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
Connection closed by foreign host.
[user@server ~]$


x.x.x.x is an IP placeholder just to add.



In theory, after the Escape character is '^]'. line, the script should have ran the ! U1 getvar "internal_wired.ip.timeout.value" command.



Also, we should have had an expected output of "10".



When I first wrote this script, I initially did not have the END_SSH command in it. A colleague introduced that to me and said to wrap the telnet commands in the END_SSH because of how Terminal technically jumps out of SSH when you are in telnet. I've tried utilizing END_SSH, but am not successful.



How do I get the telnet command to run successfully and get the expected output value?










share|improve this question






















  • Look into expect.

    – Shawn
    Mar 23 at 2:29






  • 1





    expect is a ridiculous overkill for that.

    – ExtraT
    Mar 23 at 3:49














0












0








0








I am attempting to write a bash script that will do the following work flow:



  1. Telnet into networked device via IP address on port 9100 telnet x.x.x.x 9100

  2. Run SGD command ! U1 getvar "internal_wired.ip.timeout.value".

  3. Expect output value of "10".

Here is the bash script I've written so far:



#!/bin/bash

IP=(x.x.x.x)


for i in $IP
do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be `"10`". Let's get started!!"
echo " "
sleep 4
echo "5....."
sleep 1
echo "4...."
sleep 1
echo "3..."
sleep 1
echo "2.."
sleep 1
echo "1."
sleep 1
echo " "
telnet $i 9100 << END_SSH
sleep 5
getvar "internal_wired.ip.timeout.value"
sleep 5
END_SSH
done


When I run this script via bash mycode.sh, I get the following output in Terminal.app:



$ bash mycode.sh 

Welcome! This script will check the timeout value of this networked device.
The expected output should be "10". Let's get started!!

5.....
4....
3...
2..
1.

Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
Connection closed by foreign host.
[user@server ~]$


x.x.x.x is an IP placeholder just to add.



In theory, after the Escape character is '^]'. line, the script should have ran the ! U1 getvar "internal_wired.ip.timeout.value" command.



Also, we should have had an expected output of "10".



When I first wrote this script, I initially did not have the END_SSH command in it. A colleague introduced that to me and said to wrap the telnet commands in the END_SSH because of how Terminal technically jumps out of SSH when you are in telnet. I've tried utilizing END_SSH, but am not successful.



How do I get the telnet command to run successfully and get the expected output value?










share|improve this question














I am attempting to write a bash script that will do the following work flow:



  1. Telnet into networked device via IP address on port 9100 telnet x.x.x.x 9100

  2. Run SGD command ! U1 getvar "internal_wired.ip.timeout.value".

  3. Expect output value of "10".

Here is the bash script I've written so far:



#!/bin/bash

IP=(x.x.x.x)


for i in $IP
do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be `"10`". Let's get started!!"
echo " "
sleep 4
echo "5....."
sleep 1
echo "4...."
sleep 1
echo "3..."
sleep 1
echo "2.."
sleep 1
echo "1."
sleep 1
echo " "
telnet $i 9100 << END_SSH
sleep 5
getvar "internal_wired.ip.timeout.value"
sleep 5
END_SSH
done


When I run this script via bash mycode.sh, I get the following output in Terminal.app:



$ bash mycode.sh 

Welcome! This script will check the timeout value of this networked device.
The expected output should be "10". Let's get started!!

5.....
4....
3...
2..
1.

Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
Connection closed by foreign host.
[user@server ~]$


x.x.x.x is an IP placeholder just to add.



In theory, after the Escape character is '^]'. line, the script should have ran the ! U1 getvar "internal_wired.ip.timeout.value" command.



Also, we should have had an expected output of "10".



When I first wrote this script, I initially did not have the END_SSH command in it. A colleague introduced that to me and said to wrap the telnet commands in the END_SSH because of how Terminal technically jumps out of SSH when you are in telnet. I've tried utilizing END_SSH, but am not successful.



How do I get the telnet command to run successfully and get the expected output value?







bash shell ssh telnet zebra-printers






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 1:22









Lasagna CatLasagna Cat

137113




137113












  • Look into expect.

    – Shawn
    Mar 23 at 2:29






  • 1





    expect is a ridiculous overkill for that.

    – ExtraT
    Mar 23 at 3:49


















  • Look into expect.

    – Shawn
    Mar 23 at 2:29






  • 1





    expect is a ridiculous overkill for that.

    – ExtraT
    Mar 23 at 3:49

















Look into expect.

– Shawn
Mar 23 at 2:29





Look into expect.

– Shawn
Mar 23 at 2:29




1




1





expect is a ridiculous overkill for that.

– ExtraT
Mar 23 at 3:49






expect is a ridiculous overkill for that.

– ExtraT
Mar 23 at 3:49













2 Answers
2






active

oldest

votes


















2














You misunderstand what "END_SSH" is. It's not a "command" - it's what's called "Here-document" in bash.



Essentially the text between the <<END_SSH and the END_SSH is a "here-document" that is piped into stdin of telnet $i 9100. So, the sleep 5 commands are never actually executed and the input reaches EOF before the connection is even established.



I don't know what exactly you are trying to accomplish, but I would guess that the following will work better. Oh, and what's with that weird IP=(x.x.x.x) declaration? Is that supposed to be an array?



#!/bin/bash

declare -a IP=(1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4)

for i in "$IP[@]"; do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be "10". Let's get started!!"
sleep 4
for j in 5..1; do
echo $j
sleep 1
done

sleep 5; echo -n $'! U1 getvar "internal_wired.ip_timeout.value"n'; sleep 5; | telnet $i 9100
done





share|improve this answer

























  • Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

    – Lasagna Cat
    Mar 23 at 6:41











  • I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

    – ExtraT
    Mar 23 at 14:18


















0














so here is what I suggest to use for the telnet part. Connect is a function being called later in a while loop, which will run over IPs ready from a file.



 Connect()
telnet $1 9100

while read -r IP
do
Connect $IP
done < filewithIPs





share|improve this answer

























  • Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

    – Lasagna Cat
    Mar 23 at 18:40











  • So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

    – Ibraheem
    Mar 24 at 2:27











  • Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

    – Lasagna Cat
    Mar 25 at 15:17











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55309723%2fhow-to-adjust-this-bash-script-to-run-telnet-commands-successfully-while-being-i%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You misunderstand what "END_SSH" is. It's not a "command" - it's what's called "Here-document" in bash.



Essentially the text between the <<END_SSH and the END_SSH is a "here-document" that is piped into stdin of telnet $i 9100. So, the sleep 5 commands are never actually executed and the input reaches EOF before the connection is even established.



I don't know what exactly you are trying to accomplish, but I would guess that the following will work better. Oh, and what's with that weird IP=(x.x.x.x) declaration? Is that supposed to be an array?



#!/bin/bash

declare -a IP=(1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4)

for i in "$IP[@]"; do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be "10". Let's get started!!"
sleep 4
for j in 5..1; do
echo $j
sleep 1
done

sleep 5; echo -n $'! U1 getvar "internal_wired.ip_timeout.value"n'; sleep 5; | telnet $i 9100
done





share|improve this answer

























  • Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

    – Lasagna Cat
    Mar 23 at 6:41











  • I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

    – ExtraT
    Mar 23 at 14:18















2














You misunderstand what "END_SSH" is. It's not a "command" - it's what's called "Here-document" in bash.



Essentially the text between the <<END_SSH and the END_SSH is a "here-document" that is piped into stdin of telnet $i 9100. So, the sleep 5 commands are never actually executed and the input reaches EOF before the connection is even established.



I don't know what exactly you are trying to accomplish, but I would guess that the following will work better. Oh, and what's with that weird IP=(x.x.x.x) declaration? Is that supposed to be an array?



#!/bin/bash

declare -a IP=(1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4)

for i in "$IP[@]"; do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be "10". Let's get started!!"
sleep 4
for j in 5..1; do
echo $j
sleep 1
done

sleep 5; echo -n $'! U1 getvar "internal_wired.ip_timeout.value"n'; sleep 5; | telnet $i 9100
done





share|improve this answer

























  • Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

    – Lasagna Cat
    Mar 23 at 6:41











  • I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

    – ExtraT
    Mar 23 at 14:18













2












2








2







You misunderstand what "END_SSH" is. It's not a "command" - it's what's called "Here-document" in bash.



Essentially the text between the <<END_SSH and the END_SSH is a "here-document" that is piped into stdin of telnet $i 9100. So, the sleep 5 commands are never actually executed and the input reaches EOF before the connection is even established.



I don't know what exactly you are trying to accomplish, but I would guess that the following will work better. Oh, and what's with that weird IP=(x.x.x.x) declaration? Is that supposed to be an array?



#!/bin/bash

declare -a IP=(1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4)

for i in "$IP[@]"; do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be "10". Let's get started!!"
sleep 4
for j in 5..1; do
echo $j
sleep 1
done

sleep 5; echo -n $'! U1 getvar "internal_wired.ip_timeout.value"n'; sleep 5; | telnet $i 9100
done





share|improve this answer















You misunderstand what "END_SSH" is. It's not a "command" - it's what's called "Here-document" in bash.



Essentially the text between the <<END_SSH and the END_SSH is a "here-document" that is piped into stdin of telnet $i 9100. So, the sleep 5 commands are never actually executed and the input reaches EOF before the connection is even established.



I don't know what exactly you are trying to accomplish, but I would guess that the following will work better. Oh, and what's with that weird IP=(x.x.x.x) declaration? Is that supposed to be an array?



#!/bin/bash

declare -a IP=(1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4)

for i in "$IP[@]"; do
echo " "
echo "Welcome! This script will check the timeout value of this networked device."
echo "The expected output should be "10". Let's get started!!"
sleep 4
for j in 5..1; do
echo $j
sleep 1
done

sleep 5; echo -n $'! U1 getvar "internal_wired.ip_timeout.value"n'; sleep 5; | telnet $i 9100
done






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 23 at 3:41

























answered Mar 23 at 3:27









ExtraTExtraT

1363




1363












  • Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

    – Lasagna Cat
    Mar 23 at 6:41











  • I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

    – ExtraT
    Mar 23 at 14:18

















  • Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

    – Lasagna Cat
    Mar 23 at 6:41











  • I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

    – ExtraT
    Mar 23 at 14:18
















Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

– Lasagna Cat
Mar 23 at 6:41





Thank you for your entry. To answer your question: I am attempting to check my list of networked devices to make sure their timeout values are set to 10. By default, many of them are set to 50. You're right, the IP variable needs to be an array at a later time, but I am using one IP address for now to better understand the logic first. I tried your code, and I received "?" as the output instead of "10". Would you happen to know why it's doing this, instead of outputting the expected value?

– Lasagna Cat
Mar 23 at 6:41













I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

– ExtraT
Mar 23 at 14:18





I don't know anything about Zebra devices, so the command I put in might not be correct. I tested that code as an HTTP client and it worked well. Verify that the ! U1 ... command is correct and also try adjusting the sleep values.

– ExtraT
Mar 23 at 14:18













0














so here is what I suggest to use for the telnet part. Connect is a function being called later in a while loop, which will run over IPs ready from a file.



 Connect()
telnet $1 9100

while read -r IP
do
Connect $IP
done < filewithIPs





share|improve this answer

























  • Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

    – Lasagna Cat
    Mar 23 at 18:40











  • So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

    – Ibraheem
    Mar 24 at 2:27











  • Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

    – Lasagna Cat
    Mar 25 at 15:17















0














so here is what I suggest to use for the telnet part. Connect is a function being called later in a while loop, which will run over IPs ready from a file.



 Connect()
telnet $1 9100

while read -r IP
do
Connect $IP
done < filewithIPs





share|improve this answer

























  • Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

    – Lasagna Cat
    Mar 23 at 18:40











  • So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

    – Ibraheem
    Mar 24 at 2:27











  • Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

    – Lasagna Cat
    Mar 25 at 15:17













0












0








0







so here is what I suggest to use for the telnet part. Connect is a function being called later in a while loop, which will run over IPs ready from a file.



 Connect()
telnet $1 9100

while read -r IP
do
Connect $IP
done < filewithIPs





share|improve this answer















so here is what I suggest to use for the telnet part. Connect is a function being called later in a while loop, which will run over IPs ready from a file.



 Connect()
telnet $1 9100

while read -r IP
do
Connect $IP
done < filewithIPs






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 2:26

























answered Mar 23 at 16:09









IbraheemIbraheem

748




748












  • Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

    – Lasagna Cat
    Mar 23 at 18:40











  • So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

    – Ibraheem
    Mar 24 at 2:27











  • Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

    – Lasagna Cat
    Mar 25 at 15:17

















  • Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

    – Lasagna Cat
    Mar 23 at 18:40











  • So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

    – Ibraheem
    Mar 24 at 2:27











  • Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

    – Lasagna Cat
    Mar 25 at 15:17
















Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

– Lasagna Cat
Mar 23 at 18:40





Thank you for your entry. I may need to clarify that I am SSH-ing into a server local to these networked devices first, and while already in SSH, I am doing telnet x.x.x.x 9100 which doesn't require any usernames or passwords to be passed.

– Lasagna Cat
Mar 23 at 18:40













So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

– Ibraheem
Mar 24 at 2:27





So is it possible to place a script on that server so that you can run it from there? Or just try to add the Connect function in your original script, and then call it the point you need it. I've updated the function and removed username/password. This is a rather clean way to run commands on a remote device

– Ibraheem
Mar 24 at 2:27













Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

– Lasagna Cat
Mar 25 at 15:17





Yes, from how our infrastructure is setup, we are encouraged to SSH into the servers local to the networked devices in that area first. I scp the .sh to the server first, then SSH in, then bash myscript.sh when I'm in.

– Lasagna Cat
Mar 25 at 15:17

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55309723%2fhow-to-adjust-this-bash-script-to-run-telnet-commands-successfully-while-being-i%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현