Z
Z
zigrus2017-05-04 16:14:14
linux
zigrus, 2017-05-04 16:14:14

How to write a Linux script on Win10 to check computers on the network?

I need to read the list of computers from a text file, one name per line,
then ping them one by one, if the computer is on, then we write its name into one file
if the computer is turned off, then we write its name into another file
in cmd bat, I did it easily,
but in Linux under Win10 with all the latest updates can't do it,
writes something about DO and that's it. tried all the examples from this and other articles
the error may be different but the
error does not work when reading the list of files.
#!/bin/bash
for iplist1 in bank_router_ip.txt
do
echo "$iplist1"
done
[email protected]:/mnt/c/Users/IEU$ sh test
: not foundst:
: not foundst:
: not foundst:
: not foundest:
: not foundest:
: not foundest:
test: 36: test: Syntax error: end of file unexpected (expecting "done")
#!/bin/bash
cat bank_router_ip.txt | while readp; do
echo $p
done
[email protected]:/mnt/c/Users/IEU$ sh test
: not foundst:
: not foundst:
: not foundst:
: not foundest:
: not foundest:
test: 14: test: Syntax error: " done" unexpected (expecting "do")
#!/bin/bash
for planet in Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto
do
echo $planet
done
[email protected]:/mnt/c/Users/IEU$ sh test
: not foundst :
test: 4: test: Syntax error: word unexpected (expecting "do")
what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark Hole, 2017-05-04
@abyrkov

#!/bin/bash
list=$(cat file.txt)
for ip in $list
do
echo $ip
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question