LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-25-2013, 01:45 AM   #1
SirTonic
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Rep: Reputation: Disabled
Bash ping script


Hello,
execuse my english.

I need help with script
I have 5 networks and I need ping script with menu option.
example:
1) network 1 (10.0.0.1) network 1 is only alias
2) network 2
etc.

choose option:
Then choose option

Enter number of ping:
then enter of ping show
ping network% n%

Thanks
 
Old 04-25-2013, 02:47 AM   #2
evo2
Senior Member
 
Registered: Jan 2009
Location: Japan
Distribution: Debian
Posts: 4,822

Rep: Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022
Hi,

this looks a little bit like a homework question. Please note that although we are happy to help, we won't do your homework for you. Show us what you have tried and tell us where you are having trouble, then we can help point you in the right direction.

If this is not a homework question, why do you want and interactive menu driven program for this? Is there something wrong with using ping directly on the commandline?

Evo2.
 
Old 04-25-2013, 01:40 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
Do you know how to do each of the steps individually?

Do you know how to ping a single host?
Can you check the result of that and perform some action based on the result?

Can you ask for and receive user input, and check that for various values?
(Hint, check out the select loop and case statement.)

Once you have these figured out, you can put them together into a full script.

Good luck!
 
Old 05-07-2013, 04:00 AM   #4
SirTonic
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
It isn't homework.
I need this script to our Technical Service.
In windows I use this bat.file
Code:
@ECHO OFF
echo ________________________________
echo.

:DOTAZ
echo Volba 1) Rozhrani 10.242.37.xxx
echo Volba 2) Rozhrani 133.120.1.xxx
echo Volba 3) Ukoncit
echo ________________________________
echo.

set choice=
set /p choice=Vyberte volbu: 
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto IP1
if '%choice%'=='2' goto IP2
if '%choice%'=='3' goto UKONCIT
ECHO Moznost "%choice%" neexistuje! Opakujte volbu.
goto DOTAZ

:IP1
echo.
echo Zadejte koncove cislo IP adresy:
echo ________________________________
echo.

set cislo=
set /p cislo=Zadejte cislo: 
if not '%cislo%'=='' set choice=%cislo:~0,1%
if not '%cislo%'=='' goto KONTROLA1
ECHO Moznost "%cislo%" neexistuje! Opakujte volbu.
goto IP1

:KONTROLA1
echo.
PING 10.242.37.%cislo% -n 10
goto end

:IP2
echo.
echo Zadejte koncove cislo IP adresy
echo.

set cislo=
set /p cislo=Vyber volbu: 
if not '%cislo%'=='' set choice=%cislo:~0,1%
if not '%cislo%'=='' goto KONTROLA2
ECHO Moznost "%cislo%" neexistuje! Opakujte volbu.
goto IP2

:KONTROLA2
echo.
PING 133.120.1.%cislo% -n 10
goto end


:UKONCIT
echo.
echo Konec davky
goto end
:end
And I don't know shell commands
Can you help me?
 
Old 05-07-2013, 09:36 AM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 13,803

Rep: Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365
Quote:
Originally Posted by SirTonic View Post
It isn't homework.
I need this script to our Technical Service. In windows I use this bat.file

And I don't know shell commands Can you help me?
Yes, we can help you, but you do need to show some effort of your own. There are MANY easily found bash scripting tutorials you can find, and the shell command to ping is (obviously enough), called "ping". Also, there are many already written scripts to do exactly what you're after, and Google can show them to you, like this one:
http://www.thelinuxtips.com/2012/06/...ultiple-hosts/
 
Old 05-09-2013, 12:30 AM   #6
SirTonic
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
I understand

Quote:
Originally Posted by TB0ne View Post
Yes, we can help you, but you do need to show some effort of your own. There are MANY easily found bash scripting tutorials you can find, and the shell command to ping is (obviously enough), called "ping". Also, there are many already written scripts to do exactly what you're after, and Google can show them to you, like this one:
http://www.thelinuxtips.com/2012/06/...ultiple-hosts/
I understand you,
ad1) but I don't want multiple host in txt file. I need choose some subnet and choose last oktet IP host and number of pings
ad2) It doesn't solve the menu, where I choose subnet and last oktet from host IP

So and only convert my .bat file to bash script

In my bat file is easy to view what I want
so where is the problem?

You think I'm on the net looking for a solution? I do not need to learn the lengthy script. The only thing I need to convert my bat file to a shell script, or on the basis of my bat file to create a shell script.

Try to understand me
 
Old 05-09-2013, 01:18 AM   #7
evo2
Senior Member
 
Registered: Jan 2009
Location: Japan
Distribution: Debian
Posts: 4,822

Rep: Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022
Hi,

LQ is about spreading knowledge. If you are not interested in learning and just want someone to simply provide a ready made solution, you're not likely to find much help here. That sort of help usually comes in the form of paid contractors/consultants.

Evo2.
 
1 members found this post helpful.
Old 05-09-2013, 02:49 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,534
Blog Entries: 51

Rep: Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604
Or phrased differently: only people who want to learn can be taught.

@OP: using a menu option means using "select" ('man bash'):
Code:
LIST="item0 item1 item2"
select ITEM in $LIST; do 
 case $ITEM in
  item*) echo $ITEM;;
      *) echo hell no;;
 esac
done
 
1 members found this post helpful.
Old 05-10-2013, 10:05 AM   #9
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 13,803

Rep: Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365
Quote:
Originally Posted by SirTonic View Post
I understand you,
ad1) but I don't want multiple host in txt file. I need choose some subnet and choose last oktet IP host and number of pings
ad2) It doesn't solve the menu, where I choose subnet and last oktet from host IP

So and only convert my .bat file to bash script

In my bat file is easy to view what I want so where is the problem?

You think I'm on the net looking for a solution? I do not need to learn the lengthy script. The only thing I need to convert my bat file to a shell script, or on the basis of my bat file to create a shell script.

Try to understand me
We do understand you: you want someone to write a script for you, and you don't want to be bothered learning anything. Thanks, but no. If you don't want to put any effort into doing work that you're getting PAID to do, why should we do your work for you, FOR FREE???.

You've been pointed to resources to help you solve your problem, and have folks willing to HELP you...this means putting some effort in of your OWN, rather than being lazy and somewhat rude, and expecting others to do your work for you. Again, show some effort, post what you've written/tried, and we will be happy to help.
 
Old 05-20-2013, 08:14 AM   #10
SirTonic
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
For your information:

ad 1) This work is not paid, it is a personal initiative
ad 2) The fact that I can not write script in Linux is only one.
I can not learn scripting, in this time.

I just need advice or or rewrite my bat file into a shell script

Thats all.
 
Old 05-20-2013, 09:05 AM   #11
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 13,803

Rep: Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365Reputation: 2365
Quote:
Originally Posted by SirTonic View Post
For your information:

ad 1) This work is not paid, it is a personal initiative
ad 2) The fact that I can not write script in Linux is only one. I can not learn scripting, in this time.

I just need advice or or rewrite my bat file into a shell script
Thats all.
It's been about a month since you first posted...MORE than enough time for you to have looked at the sample script you were provided, and look at one of the THOUSANDS of bash-scripting tutorials, and made it work. Since it's your 'personal initiative', you should be WANTING to learn, rather than asking someone to do it for you.

You WERE given advice, a sample script, and there are even links on LQ (and in my posting signature), to bash scripting tutorials. You've not done any of it, and AGAIN, we are not going to write your script FOR YOU. You will NEVER be able to write a script if you don't actually TRY TO DO IT.

Either look at the sample and scripting tutorials and put some effort into it (which WILL get you lots of help), or get someone else to write your script for you.

Last edited by TB0ne; 05-20-2013 at 02:58 PM.
 
Old 05-20-2013, 02:47 PM   #12
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 2,726
Blog Entries: 3

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
Quote:
Originally Posted by SirTonic View Post
For your information:

ad 1) This work is not paid, it is a personal initiative
ad 2) The fact that I can not write script in Linux is only one.
I can not learn scripting, in this time.

I just need advice or or rewrite my bat file into a shell script

Thats all.
Fries with that?
Code:
#!/bin/bash
Go!
 
1 members found this post helpful.
Old 05-20-2013, 02:54 PM   #13
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,317
Blog Entries: 1

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
You can always hire someone to do something like this for you. You are unlikely to find someone that is going to take the time to do it for you for free.

https://www.elance.com/

Or google: Programmers for hire
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script that read from file and ping remote host zunder1990 Linux - Newbie 4 12-19-2012 10:15 AM
Bash script to ping a range or own IP-range ugurgazi Programming 11 04-29-2011 08:54 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
Bash Script to Continuously Ping Server and Send Email schaefer76 Linux - Newbie 4 05-07-2010 09:54 AM
Bash script, if else statement to ping & ssh connection to correct i.p. VipX1 Linux - Newbie 2 12-31-2009 11:05 PM


All times are GMT -5. The time now is 12:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration