0

The script I want to use is the one below. The issues is finding a way to run pings from the device that I have connected to in the bash script.. The ssh is opened by running a script, and I don't have direct access to the ssh info. The script calls for me to put in my creds to connect. I appreciate any help.

#!/bin/bash
#Ol mnqnzf
echo "Enter the alarm ticket contents."
pluma Contents
cat Contents | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" > ipfound
for IP in $(cat ipfound);
do
        ping -c 5 $IP
        echo ""
done
rm ipfound
rm Contents
  • Welcome to SO! You don't mention what happens when you run your script, or how it's different from what you expected. Is it safe to assume that the behavior you're seeing is "The script asks me to put my creds in. I do so, and it gives me a remote shell and nothing else happens. When I log out with `exit`, the script starts pinging from my local machine. I wanted it to ping from the remote host instead, without giving me a shell"? – that other guy Jul 23 '20 at 22:42
  • What does `ssh-instance cta` do? – Cyrus Jul 23 '20 at 22:45
  • @the other guy The current script format doesn't work as it will ping on the local network, instead of running the ping command on the ssh. – Ronald Tidwell Jul 23 '20 at 22:59
  • @Cyrus That script is used to open up a ssh connection to a remote system. I do not have details on the exact scripting. It will prompt me for my creds, and then finish opening the ssh connection. – Ronald Tidwell Jul 23 '20 at 22:59
  • So basically I removed the notation about ssh-instance. I guess the really question is I just need to figure out how to make the script run locally, except run the ping on the ssh device. – Ronald Tidwell Jul 23 '20 at 23:01
  • You can read all about passing commands to ssh and similar tools in the duplicate, and a further example [here](https://stackoverflow.com/questions/4412238/what-is-the-cleanest-way-to-ssh-and-run-multiple-commands-in-bash). Keep in mind that your file is created on the local machine, so you either have to include its contents or create it on the server – that other guy Jul 23 '20 at 23:05
  • @thatotherguy Not sore what I am getting hung up on. `code #!/bin/bash ssh me@server.com < – Ronald Tidwell Jul 24 '20 at 02:04
  • You're saying there's no output from ping at all? – that other guy Jul 24 '20 at 06:12
  • @thatotherguy When I put in that code above it never even reaches the ping. It asks for my password I put that in, and then it ends up sitting at a blank line no prompt. It must have something to do with that error "Pseudo-terminal will not be allocated because stdin is not a terminal" I think – Ronald Tidwell Jul 24 '20 at 21:23
  • The system I am using is based of CentOS. – Ronald Tidwell Jul 24 '20 at 21:45
  • @RonaldTidwell The message would generally be harmless, but you can use `ssh -tt` to allocate a pty anyways – that other guy Jul 24 '20 at 22:39
  • So what would be causing it to not get a ssh prompt so the rest of the command can run? – Ronald Tidwell Jul 25 '20 at 05:04

0 Answers0