-1

Can someone help me with the syntax for a simple bash script that trying to write:

echo ping -c 1
echo nslookup

Basically I want to receive output of one line from the ping and the nslookup information for a domain that I'm checking. Unfortunately I'm unable to get this correctly.

P.s. this is basically the first thing that I'm trying to accomplish in bash.

Thank you in advance!

Daan
  • 940
  • 10
  • 22
  • Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User. – moritzg Jun 14 '17 at 06:04

3 Answers3

1

Thank you for the provided information on the matter. I felt little ashamed from the nature of my question so I spent little more time to read. The solution that I found is the following:

#!/bin/bash
for i in $*;do
ping -c 1 $i &
nslookup $i &
done
#

' Once I added the scrit to the /bin folder I used the commands:

chmod +x "script name"
dos2unix ""scrit name" 

so not I'm able to use it only by typing the name of the script.

  • Delete ampersand `&` at the end of strings. Use script: `scriptname google.com ya.ru anysite.net` and you will get info about google.com, ya.ru and anysite.net. – zombic Jun 14 '17 at 11:36
  • Thank you zombic, after I removed the ampersands the session was over after the execution. I was wondering what was causing that. – Veselin Trendafilov Jun 15 '17 at 12:58
0

Hi i would be better if you elaborate your problem, if you want one line output for ping command filter using head

eg ping www.google.com | head -n 1

or if you are thinking of sending one packet of data to the server

ping -n 1 www.google.com

nslookup www.google.com

and if your are writing Bash Script

#!/bin/bash ping -n 1 www.google.com nslookup www.google.com

save the file give execute permission and run

Please let me know i answered your question

Shailesh
  • 59
  • 6
  • Thank you, I actually find a solution on the matter. You can check it in the answer that I left. Thank you so much for providing me with that information as well. – Veselin Trendafilov Jun 14 '17 at 08:53
0

hi after writing and saving script and giving permission to the script just go the folder and ./

of else you just can use sh

Shailesh
  • 59
  • 6