So anyways, I'm working on a small PHP website/script, and as one of the features I'd like to be able to run a Ping Test on the current domain the PHP script is running on. I don't know much about Ping test (well, I know what they do, I just don't know how to run them in PHP) Please let me know how to do it and get same result as : http://www.ipfingerprints.com/ping.php
There is no built-in method to running a ping test in PHP, you must use exec to run the command.
exec('ping -n 4 $ip', $output, $retval);
If you want to send ICMP packets in php you can take a look at this Native-PHP ICMP ping implementation, but I didn't test it.
Related
I'm checking for comprehension on a homework question for my class. I looked over the man pages for ping and the -t flag didn't have a lot of info on it so I had to infer quite a bit. If someone could verify that my understanding is correct, and perhaps point me to a resource that explains -t flag better than the man pages, I'd appreciate it.
The question:
Write a bash command line that will verify that no more than two network devices are used to pass messages from the syccuxas01.pcc.edu server to the www.pcc.edu server. Use ping with the -t option and see the TTL Details section of man ping.
ping -t 2 www.pcc.edu
My understanding of what that command means and thoughts: The question is poorly worded as "network devices" would be more accurately described as hops. Hops are the steps that a packet of information takes to get to the server you want to send it to, much like if you're going on a car trip, you'll drive through other towns along the way to your destination.
So if we ping the TTL (time to live, which is very dramatic sounding!) [ aka -t ] twice, we're able to get results, which means that there are 2 "hops" to get to www.pcc.edu from the server we access through Putty. TTL from what I understand means how many hops the ping will try to use to send a packet. So ping -t 1 www.pcc.edu will fail. ping -t 3 www.pcc.edu will succeed, but it's using 3 hops, which is not what we want to solve the problem.
I'm a total beginner to MySQL, I'm more of a firmware specialist. I'm working on an application where I will be getting GPS coordinates from a microcontroller + cellular device and I would like some way to store the coordinates and do processing on them. I figured a database hosted on a server made the most sense, which is what has brought me to MySQL.
Basically, I'm wondering what the basic protocol is for sending data to a MySQL server over an internet connection (my device has data). Like how do I connect to the server and publish data to it?
I'm experienced with MQTT and I think I could do TCP as well but I'm looking for a protocol that is not super power-intensive and I can't use anything that requires an operating system, like a python script.
To be clear, I am NOT asking you to tell me every step for how this is done, but basically what protocol and what tools could I use? Anything you can tell me would be appreciated.
I was thinking that I could use the MySQL client C code to help write a driver that could allow me to connect to the server. I'm experienced with writing drivers and the microcontroller I'm using uses C.
You need no direct connection to the DB at all. Your cellular device should be able to establish tcp connection to the ipaddress/port and to send the byte-stream through the connection. It can be the dumb unidirectional protocol with losses.
You need some service that can listen on the other side, that can parse your byte-stream, can fetch the correct packets from it and then send the data to the database. Speaking frankly that service can even be written in linux shell:
nc -lk 1234 | collector.sh
where collector.sh is a script like that:
#!/bin/sh
while read LINE
do
# $LINE parsing and all the staff
mysql -e "INSERT INTO mygps.nmea (lat,lon,dtime) VALUES ($LAT, $LON, $DTIME);"
done <<< /dev/stdin
####
Sure it isn't a best solution but it was really helpful for me at the very beginning. Then you can proceed the gathered data in any desired way.
Build a simple server that communicates with whatever gathered data and then use the server so send the data to MySQL with the help of MySQL connector. Building part of the protocol will quite time consuming. - nbk
If you "can't use anything that requires an operating system" you need some middleware that can run the MySQL client driver to talk to the database, you will then use MQTT to pass data between your sensor and the middleware. If you don't want to write this middleware yourself, something like Node-RED might come handy.
You certainly can reimplement the driver for your MC, though I personally would not want to waste the time on something like this when I can assemble a solution from existing components. Database protocols are typically chatty, synchronous, and sensitive to network quality, and I wouldn't want to waste my MC cycles on that when I can make middleware do that asynchronously. - mustaccio
Simply "reverse ssh port forwarding"? That can be done, I think, with a single ssh command at one (or both) end of the connection. MySQL, by default, needs the client to connect on port 3306 to the server. - rick-james
I have written several shell scripts with tcl/tk and I run it on the machine with the user group, when I give it to another user with different machine or from another IP it gives error.
Spawn/bin/bash
But if I run it from my machine where I wrote it, it runs correctly.
The header is so defined.
#! / Usr/bin/expect -f
#
Can you tell me that I have not added or am missing so that it can run from any pc and any user?
From the question you have posted, it looks like to me one or more of following issues. Apart from that the real problem looks to me is in /bin/bash. Check manually once in the machine where the problem lies.
First check manually from other machine where the issue is present. Checking is easy.
which expect
expect
spawn /bin/bash
Have you got the error? Also check if there is -
Difference in expect version
Permission issue
Have you considered the scenario where you are prompted for storing RSA key? Relevant in case you are connecting to other machines from the host you are running the program.
Thank,
Mr. Bordoloi
I invoked ping process on ubuntu, then while ping works the IP of server has been changed.
another ping process from the same machine showed me the correct IP, but the first process still printing old IP.
that can be variable in ping, initialized once when it start (I guess, anybody here can confirm it?).
however I wonder to know how it works.
Couldn't it be an DNS Cache problem?
If you think yes, try that:
sudo /etc/init.d/dns-clean start
This was my previous question:
Can someone give me simple example in C, of using pipe() system call to and use ssh to connect to a remote server and execute a simple ls command and parse the reply. Thanks in advance, [...]
I got an answer for that, but I need something more.
I would like to ask how to use a pipe and connect to a remote server using ssh, then open mysql and execute a simple query like SELECT * FROM tables;.
Thanks in advance!
Are you doing this for a challenge?, if yes that's cool because you are doing a hard thing to the end, if not derobert suggestion is the best solution in case you want to communicate with the MySQL server.