paxmultimedia.blogg.se

Ping multiple computers and output to text file
Ping multiple computers and output to text file








ping multiple computers and output to text file

And you're back in the original shell you logged in with putty, you can now close putty and have a coffee. To detach from screen you need to enter Ctrl+A D (hold Ctrl, press A, release Ctrl and press D). It will run forever, and keep echoing a couple of messages while writing to the log file. You're now in a shell that is being accessed through a socket in /var/run, this shell will not close once if you detach from it and then close putty (actually if you just close putty the OS will figure things out and not close the shell anyway, but let's do a proper detach for educational reasons). Run: screenĪnd apparently nothing changes. Now screen comes into the scene (you installed it, right?). But do not run it yet, since it will stop once you close putty. Let's assume that this script is saved to a file called pingservers.sh. Ssh -i ~/.ssh/host1tohost2 'cat /home/me/myservers/servers.txt' | # >$LOGFILE # clear log file (see comments) The infinite loop script you need is: #!/bin/sh

ping multiple computers and output to text file

This assumption is needed since we will be using this path in a script at host1. Let us assume that the file servers.txt is at /home/me/myservers/servers.txt on host2. This allows for login from host1 to host2 without an interactive password prompt. You shall copy ~/.ssh/host1tohost2.pub to host2: scp ~/.ssh/host1tohost2.pub host2Ĭreate ~/.ssh in host2 and move host1tohost2.pub there, then create a file called authorized_keys in that directory: mkdir -f ~/.ssh That command will generate the following files: ~/.ssh/host1tohost2 Keep host1 safe! Thanks to this key anyone in control of host1 also gains control of host2 (to the extent the user permissions allow). It will ask for a passphrase, to perform the script automatically (without the need for manual input of a passphrase) you shall set it to an empty passphrase.

ping multiple computers and output to text file

To perform this you need to run: ssh-keygen -f ~/.ssh/host1tohost2 I suggest screen since it is a little easier for a beginner.Īlso, you need to be able to login to host2 from host1 therefore you need to setup a ssh key which will allow for login without a password.

ping multiple computers and output to text file

Let us assume that you have host1 to which you connect with ssh via putty, on this host you shall install screen or tmux (from the package manager, they shall be there). OK, I believe I understand your question now.










Ping multiple computers and output to text file