Programming :: Ping With Shell Script?
Sep 15, 2010Now I am using ping command following
ping -I eth1 192.168.1.17
I want to add to shell script but I want type myself -I and eth1 when running the bash file.
Now I am using ping command following
ping -I eth1 192.168.1.17
I want to add to shell script but I want type myself -I and eth1 when running the bash file.
I'm trying to do the following. from a php webpage click on a link, that opens a shell/cmd and runs an open ping to the device. so it must actually open a shell (for linux) or cmd (for windows) and run a ping to the specified ip. Currently i'm running an exec command, but for this i need to wait for the result to be fetched and print it out. I want to monitor it in realtime, by just clickingon the button. How to get this working?
View 1 Replies View RelatedI am using an virtual machine. where I need to ping from one machine to another. earlier I was able to ping. But after going to google.com once, I cannot ping back to this machine.
But if I gave ping -I eth1 <IP> then I can ping.
I cannot install any package, so tell me solution which includes not installing any package.
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....
Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?
Example:
Code:
>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.
I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.
View 11 Replies View RelatedIs there any way to implement a simple ping script in C (unix)? I'm programming simple OpenWRT scripts.
I have found some examples of ping in C:
[URL]
However, nothing happens, nothing is sent.
When I look at the code, in the portion where the socket is created, I can see that the socket is not binding to any interface:
Code:
if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) == -1)
{
perror("socket");
exit(EXIT_FAILURE);
}
setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &optval, sizeof(int));
Instead, it uses "setsockopt" to set some options.
My guess is that it is trying to send packets over the eth0 interface instead over the wl0 (wireless) interface (which is the one I want to use to send pings).
Now, my question is: Is there any other way to send pings in C by binding to an interface?
I have a php scriptI want it to ping list of ips from a databse(using fping) and based on the status of the values to put them in a field(status) into the database(0 if down,1 if up)i executed tghe script and it gives me this error:Thread 1 - 17:51:01 26-04-2011 4.2.2.2 alive Couldn't execute query.I cant see what 's wrongthis is the source of the php script:
<?php
require_once("conf.php");
$connection1 = mysql_connect($h, $u, $p) or die("Couldn't connect.");
[code]....
I would like to ping all my virtual hosts in virtual machine server with a oneliner. For example like this:
Code:
for i in $(seq 1 20); do if [[ $(ping host$i.virtualhostserver.com -c 2 2>/dev/null | grep "2 received") == "2 packets transmitted" ]]; then echo $i; fi; done
The problem is, that I'm afraid my if-sentence is somewhat wrong because it never gets a match even if I know, that host is up.
I can't get exec ping to work on my system. wish is located in /usr/bin/wish8.4
Code:
#!/usr/bin/wish8.4
text .txt
set in [open "/root/hosts.txt" r]
while {[gets $in line] != -1} {
[Code]....
I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
Do i have to use sed command?
Is it possible to create threads in BASH? I need a script with will ping a network to find out unused IP. in a for or while loop the pinging process is taking a very long time. I was wondering if it is possible to send multiple ping on the same time so this will speed up the scanning process.
View 5 Replies View RelatedI am new to linux and am trying to write a script that will ping IP addresses and say either online or unavailable.
View 3 Replies View RelatedIs it possible to assist in the programming Shell Scripts
Job:
To send a message to the email,All orders written in Terminal or ssh
example : ls , pwd , cat , and other
Please let me know how i will overcome this.I have tried from the past 5 days.
[root@localhost ~]# cc p.cc
In file included from p.cc:1:
/root/ping.h:2:32: warning: multi-character character constant
In file included from p.cc:1:
/root/ping.h:4: error: stray in program
/root/ping.h:2: error: invalid function declaration
[Code]...
Split programming in ns2 marc greis chapter 7 ping protocol code. I tried compiling the above program and got the errors as in error.txt I have attached. Ping.cc and ping.h also are attached. I have supplied all the required header files along with appropriate paths and yet this problem.
ATTACH]5537[/ATTACH]
pingcc.txt
pingh.txt
This applies to my 2 opensuse PC's, my Windows PC is fine.I can ping a hostname, say "PC1" but I can not ping PC1.domain.local (even the host PC can not ping it's own FQDN). When I ping just the hostname the ping stats even list the FQDN.Onto the next issue, since all my PC's, have the domain prefix domain.local, my Synology can not. I can ping it's IP and that is it. I can resolve it's name with nmblookup just fine tho and that is what is killing me. How is this not resolving.Even weirder, I can browse to "Synology" in Network Servers under places on the slab.
View 3 Replies View RelatedEven ping google's ip address doesn't work. unknown host error using backtrack4 able to browse net with these settings.
My network settings:
What's the problem with these settings...
Ive got a problem on my server ....installed Debian 5 , Webmin and than syscp settung up syscp ready ....
I try to ping "localhost" ansver ping: unknown host
I try to ping "localhost." there is a host with IP 127.0.0.1
I need it to change it in "localhost"
Is that the bind9 maybe?
I have two machines on this network, one running Ubuntu and the other running Fedora.
When I'm using the Wireless network on the Ubuntu machine, I cannot ping the Fedora machine. Everything else works. I can browse the net fine.
If I switch over to the Wired Network then I can ping the other machine.
I don't understand why ping doesn't work only over the Wireless. I can ping the router so I'm guessing it's getting blocked by the router but I didn't block ICMP traffic.
I tried asking on IRC and they ran out of ideas too to find out where the problem is.
I have a debian server installed with a static ip. Now i am able to ping my ip, but when i try to configure a domain name with the nameserver as my ip, i am not able to ping the domain name
eg:
When i ping www.google.es, i get something like:Quote:
ping www.google.es
(wait 20 seconds)
64 bytes from 66.249.92.104: icmp_seq=2 ttl:53 time=80 ms
[code].....
I just installed my first EVER bind DNS server. I am running bind9 on Ubuntu 10.04. Everything seems to be working great except one thing: If I ping a host that I have set up in bind by its HOSTNAME the pings take 5-6 seconds to reply/print to the screen between each echo response. If I ping by the host's IP address, they echo back very quickly.
I have read that IPv6 can cause this, but I have disabled it in /etc/sysctl.conf and the problem still exists.
I know everyone says this can't be a DNS issue, but this never was an issue with dnsmasq (which i was using prior), and it doesn't make sense that the ping are ONLY slow when pinging by hostname and not IP.
Configs below:
Ping by hostname - there is a 5-6 second delay between each one of the responses:
Code:
Ping by IP - the responses come VERY quickly one after the other:
Code:
/etc/resolv.conf:
Code:
Code:
rev.0.168.192.in-addr.arpa:
Code:
So, I have an Virtual Machine running CentOS 5.4. It sits behind a hardware firewall which also does NAT'ing. I've set up plenty of these, so I know for sure the firewall and NAT rules are set up correctly. From the host, I can ping anything in my subnet and the gateway. But I can't ping anything else beyond the gateway. I can perform DNS queries and when I try to ping, it finds the appropriate IP address.But from the outside, I can ping the PUBLIC address (It's a 1 public to 1 private address NAT, not 1 public to multiple private). I've tried it with IPTABLES on and off, with no change.
View 11 Replies View RelatedI have Mandriva One 2009.0 (192.168.1.100) on one box and Mandriva Free 2010.0 (192.168.1.118) on the other. I can ping router (192.168.1.1) from both of these boxes but I can't ping one box to the other and the other way around. What's going on?.
Do I have to change some settings in router?. Or is it firewall issue on those two machines?. Both of these boxes are connected by cable. Symbol of the router: TL-WR340G.
I have a situation where I am in a non-interactive shell. I have tried from within my non-interative shell to spawn an interactive shell but my output still does not goto me. Isn't there a way I can somehow go into /proc or somwhere and make the output my /dev/tty1? Or some way else to remedy this?The situation arises because I drop from my restricted shell environment (a sort of CLI interface), into the actual Linux shell. I cannot change the code of the CLI environment I am just faced with being in the linux shell environment and its non-interactive. Its very annoying to have to put > /dev/tty1 after every command I type.
Not to mention it seems damn near impossible to get pagers like more and less to work properly when your in a non-interactive shell.
I have a shell script that I would like to log to stdout and also to a file.....much like using tee. I would like to, instead of calling the script and piping to tee...i would like for the script to tee itself.
View 4 Replies View Relatedi got to build my own linux shell for my project
View 5 Replies View RelatedI have been searching most of today and am stuck on getting a variable into an awk portion of my bash script. I have this working:
Code:
#!/bin/sh
SRC=/var/log/mail.log
DEST=/var/www/output/myFile.txt
VAR=userName@myDomain.tld
[code]....
Can awk take a shell variable? Or do I have to do something completely different?
I need to push out a file to a bunch of linux and solaris boxes so I was hoping to use a script to automate the process with scp (or something else / better) - how can I batchmode scp so that it will do this? I should mention the servers do have keys set up so I do not have to authenticate manually or through something like an expect script...
View 4 Replies View Related