S
S
Strabbo2018-12-03 17:12:21
bash
Strabbo, 2018-12-03 17:12:21

Why is bash script not working?

bash script not working. the script is connected on a telnet drives in a command, but does not carry out it.

#!/bin/bash

for ip in `cat ip.txt`

do

{ echo "admin+t/r"; sleep 2; echo "pass"; sleep 2; echo "ping 192.168.20.35"; sleep 2; echo "quit" ;} | telnet $ip  

done

the script is run on ubuntu.
5c053974c6aa9493784458.png
echo -e "ping 192.168.20.35" doesn't help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-12-03
@q2digger

why not make it easier?

[email protected]:~ $ ssh [email protected] ping 192.168.109.1
[email protected]'s password:
  SEQ HOST                                     SIZE TTL TIME  STATUS
    0 192.168.109.1                              56  64 0ms
    1 192.168.109.1                              56  64 0ms
    2 192.168.109.1                              56  64 0ms
    3 192.168.109.1                              56  64 0ms

If you throw a key on Mikrotik ssh, then you will not need to enter a password

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question