0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

raspberry pi 1 model bで、with pixel その3

Last updated at Posted at 2017-01-08

概要

起動時、IPアドレスを表示させてみた。

写真

MVC-003S.JPG

環境

Raspberry pi 1 model b(element14)
raspbian 2016-11-25 jessie with pixel
sd_card MF-RUMSD08GL elecom
HDMI to VGA adapter(amazon)
usb keyboard(nec)
usb mouse(nec)

準備

aptitude install apache2 php5

設定

ブラウザのアドレスをhttp://localhost/ip.phpにする。

サンプルコード

<HTML>
<BODY>
<h1>

<?php

$cmd = "ifconfig";
$data = `$cmd`;

foreach (preg_split("/\n\n/", $data) as $int) 
{
	preg_match("/^([A-z]*\d)\s+Link\s+encap:([A-z]*)\s+HWaddr\s+([A-z0-9:]*).*" .
			"inet addr:([0-9.]+).*Bcast:([0-9.]+).*Mask:([0-9.]+).*" .
			"MTU:([0-9.]+).*Metric:([0-9.]+).*" .
			"RX packets:([0-9.]+).*errors:([0-9.]+).*dropped:([0-9.]+).*overruns:([0-9.]+).*frame:([0-9.]+).*" .
			"TX packets:([0-9.]+).*errors:([0-9.]+).*dropped:([0-9.]+).*overruns:([0-9.]+).*carrier:([0-9.]+).*" .
			"RX bytes:([0-9.]+).*\((.*)\).*TX bytes:([0-9.]+).*\((.*)\)" .
			"/ims", $int, $regex);
	if (!empty($regex)) 
	{
		echo $regex[4];
	}
}

?>

</h1>
</BODY>
</HTML>


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?