正規表現 英数記号:\s!-~

英字:[A-Za-z]

$var="My name is Tom";
echo preg_match("/[A-Za-z]/", $var);

数字:[0-9]

$var="My name is Tom, 19years";
echo preg_match("/[0-9]/", $var);

英数字:[A-Za-z0-9]

$var="今年の桜は綺麗ね";
echo preg_match("/[A-Za-z0-9]/", $var);

英数記号:!”\#$%&@'()*+,-./_

$var="hoge@gmail.com";
echo preg_match("/[\#$%&@'()*+,-._]/", $var);
$var="hoge@gmail.com";
echo preg_match("/[\s!-~]/", $var);

あれ!? ”\#$%&@'()*+,-._”と”\s!-~”、一緒だ。
すげーーーーーーーーーーーー

–suppress-common-lines

diffをした時に、違いのみ表示する。

[vagrant@localhost test]$ cat test.html
1 8411 東証1部 (株)みずほフィナンシャルグループ 03/28 1 71.1 -0.18% -0.3 96,741,900
2 8306 東証1部 (株)三菱UFJフィナンシャル・グループ 03/28 5 50.5 -0.56% -3.1 41,004,400
3 1357 東証ETF (NEXT FUNDS) 日経ダブルインバース上場投信 0 3/28 1,205 +2.99% +35 34,491,855
4 3765 東証1部 ガンホー・オンライン・エンターテイメント(株) 0 3/28 410 -3.53% -15 28,158,000
5 9437 東証1部 (株)NTTドコモ 03/28 2,417 -1.31% – 32 22,719,600 [vagrant@localhost test]$ ls
test.html work
[vagrant@localhost test]$ cp test.html copy.html
[vagrant@localhost test]$ ls
copy.html test.html work
[vagrant@localhost test]$ vi copy.html
[vagrant@localhost test]$ diff -y test.html copy.html
1 8411 東証1部 (株)みずほフィナンシャルグループ | 1 8 411 東証1部 みずほフィナンシャルグループ 03/28
2 8306 東証1部 (株)三菱UFJフィナンシャル・グルー 2 8 306 東証1部 (株)三菱UFJフィナンシャル・グルー
3 1357 東証ETF (NEXT FUNDS) 日経ダブルインバース上場 3 1 357 東証ETF (NEXT FUNDS) 日経ダブルインバース上場
4 3765 東証1部 ガンホー・オンライン・エンターテイメ 4 3 765 東証1部 ガンホー・オンライン・エンターテイメ
5 9437 東証1部 (株)NTTドコモ 03/28 2,417 \ 5 9 437 東証1部 (株)NTTドコモ 03/28 2,417
[vagrant@localhost test]$ diff -y –suppress-common-lines test.html copy.html
1 8411 東証1部 (株)みずほフィナンシャルグループ | 1 8411 東証1部 みずほフィナンシャルグループ 03/28
5 9437 東証1部 (株)NTTドコモ 03/28 2,417 \ 5 9437 東証1部 (株)NTTドコモ 03/28 2,417

ほう、なるほど~

linux sudo

$ sudo -V
Display the version of sudo command currently used.

[vagrant@localhost ~]$ sudo -V
Sudo バージョン 1.8.6p3
Sudoers policy plugin version 1.8.6p3
Sudoers file grammar version 42
Sudoers I/O plugin version 1.8.6p3
ん、なんだこれ?

$ sudo -l
Display command that the user can (or cannot) do on the current host by using the sudo command.

[vagrant@localhost ~]$ sudo -l
このホスト上でユーザー vagrant
に一致したデフォルト項目:
!visiblepw, always_set_home, env_reset, env_keep=”COLORS DISPLAY
HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS”, env_keep+=”MAIL PS1 PS2
QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE”, env_keep+=”LC_COLLATE
LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES”,
env_keep+=”LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE”,
env_keep+=”LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY”,
secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

ユーザー vagrant
は次のコマンドをこのホスト上で実行できます:
(ALL) NOPASSWD: ALL

$ sudo -h
Display help for sudo command.

$ sudo -u username hoge
Execute hoge command as a username

なんか、この辺は知らんとモグリと思われるな。

linuxでの操作

[vagrant@localhost test]$ WORK_DIR=work/$(date +%Y)/$(date +%m%d)_crontab
[vagrant@localhost test]$ ls
[vagrant@localhost test]$ mkdir -p ${WORK_DIR}
[vagrant@localhost test]$ ls
work
[vagrant@localhost test]$ ls
work
[vagrant@localhost test]$ cd work
[vagrant@localhost work]$ ls
2019
[vagrant@localhost work]$ cd 2019
[vagrant@localhost 2019]$ ls
0327_crontab
[vagrant@localhost 2019]$ cd 0327_crontab
[vagrant@localhost 0327_crontab]$ ls
[vagrant@localhost 0327_crontab]$ crontab -l > crontab.old
no crontab for vagrant

なるほど、コマンドラインでも変数として扱えるのね。ほう。

dateコマンド

[vagrant@localhost ~]$ date
2019年 3月 26日 火曜日 09:15:51 JST
[vagrant@localhost ~]$ date “+%Y%m%d-%H%M%S”
20190326-091709

ふむ。

Reflection after changing crontab file

How to reflect changes after editing the contents of crontab file directly. There is no need to restart cron after changing crontab.

On Linux, it checks the modification time of cron every minute and reloads if there is a change, so change of the file of cront if you do, your changes will take effect immediately without having restart cron.

/var/spool/cron

[vagrant@localhost ~]$ /etc/rc.d/init.d/crond status
crond (pid 2614) を実行中…

ps -aef

ps: Check the processes currently running on Linux

a: display the process of terminal operation
f(option -h, option-forest): display processes in a hierarchy
e: display the command name and environment, variables being executed.

[vagrant@localhost ~]$ ps -aef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Mar24 ? 00:00:00 /sbin/init
root 2 0 0 Mar24 ? 00:00:00 [kthreadd]
root 3 2 0 Mar24 ? 00:00:00 [migration/0]
root 4 2 0 Mar24 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 Mar24 ? 00:00:00 [stopper/0]
root 6 2 0 Mar24 ? 00:00:00 [watchdog/0]
root 7 2 0 Mar24 ? 00:01:54 [events/0]
root 8 2 0 Mar24 ? 00:00:00 [events/0]
root 9 2 0 Mar24 ? 00:00:00 [events_long/0]
root 10 2 0 Mar24 ? 00:00:00 [events_power_ef]
root 11 2 0 Mar24 ? 00:00:00 [cgroup]
root 12 2 0 Mar24 ? 00:00:00 [khelper]
root 13 2 0 Mar24 ? 00:00:00 [netns]
root 14 2 0 Mar24 ? 00:00:00 [async/mgr]
root 15 2 0 Mar24 ? 00:00:00 [pm]
root 16 2 0 Mar24 ? 00:00:00 [sync_supers]
root 17 2 0 Mar24 ? 00:00:00 [bdi-default]
root 18 2 0 Mar24 ? 00:00:00 [kintegrityd/0]
root 19 2 0 Mar24 ? 00:00:03 [kblockd/0]
root 20 2 0 Mar24 ? 00:00:00 [kacpid]
root 21 2 0 Mar24 ? 00:00:00 [kacpi_notify]
root 22 2 0 Mar24 ? 00:00:00 [kacpi_hotplug]
root 23 2 0 Mar24 ? 00:00:00 [ata_aux]
root 24 2 0 Mar24 ? 00:00:00 [ata_sff/0]
root 25 2 0 Mar24 ? 00:00:00 [ksuspend_usbd]
root 26 2 0 Mar24 ? 00:00:00 [khubd]
root 27 2 0 Mar24 ? 00:00:00 [kseriod]
root 28 2 0 Mar24 ? 00:00:00 [md/0]
root 29 2 0 Mar24 ? 00:00:00 [md_misc/0]
root 30 2 0 Mar24 ? 00:00:00 [linkwatch]
root 33 2 0 Mar24 ? 00:00:00 [khungtaskd]
root 34 2 0 Mar24 ? 00:00:00 [lru-add-drain/0]
root 35 2 0 Mar24 ? 00:00:01 [kswapd0]
root 36 2 0 Mar24 ? 00:00:00 [ksmd]
root 37 2 0 Mar24 ? 00:00:00 [aio/0]
root 38 2 0 Mar24 ? 00:00:00 [crypto/0]
root 45 2 0 Mar24 ? 00:00:00 [kthrotld/0]
root 47 2 0 Mar24 ? 00:00:00 [kpsmoused]
root 48 2 0 Mar24 ? 00:00:00 [usbhid_resumer]
root 49 2 0 Mar24 ? 00:00:00 [deferwq]
root 81 2 0 Mar24 ? 00:00:00 [kdmremove]
root 82 2 0 Mar24 ? 00:00:00 [kstriped]
root 186 2 0 Mar24 ? 00:00:00 [scsi_eh_0]
root 188 2 0 Mar24 ? 00:00:00 [scsi_eh_1]
root 214 2 0 Mar24 ? 00:00:00 [scsi_eh_2]
root 262 2 0 Mar24 ? 00:00:00 [kdmflush]
root 264 2 0 Mar24 ? 00:00:00 [kdmflush]
root 332 2 0 Mar24 ? 00:00:02 [jbd2/dm-0-8]
root 333 2 0 Mar24 ? 00:00:00 [ext4-dio-unwrit]
root 338 2 0 Mar24 ? 00:00:01 [flush-253:0]
root 409 1 0 Mar24 ? 00:00:00 /sbin/udevd -d
root 513 2 0 Mar24 ? 00:00:00 [iprt-VBoxWQueue]
root 708 2 0 Mar24 ? 00:00:00 [jbd2/sda1-8]
root 709 2 0 Mar24 ? 00:00:00 [ext4-dio-unwrit]
root 771 2 0 Mar24 ? 00:00:00 [kauditd]
root 963 1 0 Mar24 ? 00:00:00 /sbin/dhclient -1 -q -cf /etc/dh
root 1148 1 0 Mar24 ? 00:00:00 auditd
root 1170 1 0 Mar24 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslo
rpc 1192 1 0 Mar24 ? 00:00:00 rpcbind
rpcuser 1214 1 0 Mar24 ? 00:00:00 rpc.statd
root 1318 1 0 Mar24 ? 00:00:46 /usr/sbin/VBoxService –pidfile
root 1357 1 0 Mar24 ? 00:00:00 /usr/sbin/sshd
root 1392 1 0 Mar24 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe –d
mysql 1632 1392 0 Mar24 ? 00:01:03 /usr/sbin/mysqld –basedir=/usr
root 2246 1 0 Mar24 ? 00:00:00 /usr/libexec/postfix/master
postfix 2250 2246 0 Mar24 ? 00:00:00 qmgr -l -t fifo -u
root 2370 1 0 Mar24 ? 00:00:06 /usr/sbin/httpd
root 2614 1 0 Mar24 ? 00:00:00 crond
jenkins 3741 1 0 Mar24 ? 00:05:14 /etc/alternatives/java -Dcom.sun
root 4085 1 0 Mar24 tty1 00:00:00 /sbin/mingetty /dev/tty1
root 4087 1 0 Mar24 tty2 00:00:00 /sbin/mingetty /dev/tty2
root 4091 1 0 Mar24 tty3 00:00:00 /sbin/mingetty /dev/tty3
root 4096 1 0 Mar24 tty4 00:00:00 /sbin/mingetty /dev/tty4
root 4098 1 0 Mar24 tty5 00:00:00 /sbin/mingetty /dev/tty5
root 4100 1 0 Mar24 tty6 00:00:00 /sbin/mingetty /dev/tty6
root 4132 409 0 Mar24 ? 00:00:00 /sbin/udevd -d
root 4133 409 0 Mar24 ? 00:00:00 /sbin/udevd -d
root 10290 1357 0 18:51 ? 00:00:00 sshd: vagrant [priv]
vagrant 10292 10290 0 18:51 ? 00:00:00 sshd: vagrant@notty
vagrant 10293 10292 0 18:51 ? 00:00:00 /usr/libexec/openssh/sftp-server
root 10300 1357 0 18:53 ? 00:00:00 sshd: vagrant [priv]
vagrant 10302 10300 0 18:53 ? 00:00:00 sshd: vagrant@notty
vagrant 10303 10302 0 18:53 ? 00:00:00 /usr/libexec/openssh/sftp-server
root 10320 1357 0 19:04 ? 00:00:00 sshd: vagrant [priv]
vagrant 10322 10320 0 19:04 ? 00:00:00 sshd: vagrant@pts/0
vagrant 10323 10322 0 19:04 pts/0 00:00:00 -bash
postfix 10798 2246 0 19:47 ? 00:00:00 pickup -l -t fifo -u
apache 10930 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10931 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10932 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10933 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10934 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10935 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10936 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
apache 10937 2370 0 19:54 ? 00:00:00 /usr/sbin/httpd
root 11000 1357 0 20:21 ? 00:00:00 sshd: vagrant [priv]
vagrant 11002 11000 0 20:21 ? 00:00:00 sshd: vagrant@pts/1
vagrant 11003 11002 0 20:21 pts/1 00:00:00 -bash
vagrant 11425 11003 0 20:26 pts/1 00:00:00 ps -aef

なにこれ?こんなに走ってるの? httpdぐらいかと思ったらww

さー今日は225が-700くらい付けてますが、今日も頑張りますかー

Linux “hostname”

“Hostname” is a command to display the host name of the system. If you are the root user(superuser), you can also change the host name.

[vagrant@localhost ~]$ hostname
localhost.localdomain

[vagrant@localhost ~]$ sudo -S “hostname”
localhost.localdomain

yum -y install perl-CGI

sudo yum -y install perl-CGIで、perl-CGIをinstall

[vagrant@localhost ~]$ sudo yum -y install perl-CGI
– 中略 -
トランザクションを実行しています
インストールしています : perl-CGI-3.51-144.el6.x86_64 1/1
Verifying : perl-CGI-3.51-144.el6.x86_64 1/1

インストール:
perl-CGI.x86_64 0:3.51-144.el6

インストール後、やり直します。

データがcgiに届きました。

#!/usr/bin/perl --
use strict;
use utf8;
use warnings;
use CGI;

my $q = new CGI;
my $param1 = $q->param('name');
my $param2 = $q->param('password');

print "Content-type:text/html\n\n";
print "<html>\n";
print "<head></head>\n";
print "<h1>Hello World, $param1 password is $param2</h1>";
print "</html>";

うーん、パラメータが付くのが気になるな。。hiddenだと、type=”password”にできないし、困ったな。。