単語のグループを生成するコードを書きました
my $uptime = `command | sed -n "xp" | cut -d" " -fx`;
上記のコマンドにより、以下の単語が得られます。
not running
以下のようなifステートメントでこの単語を使用したいと思います。
if ($uptime = $not){
$run = `command`;
$start = `start`;
変数を宣言して$not
入れ"not running"
ました。スクリプトは機能していますが、プログラムの実行中は逆です。以下のコマンドは、(「ok」のような) 変数$not
にない別の単語を与えますが、スクリプトはプログラムを再起動しています。
#!/usr/bin/perl
use warnings;
use strict;
$not = "not running";
$uptime = `command | sed -n "xp" | cut -d" " -fx`;
if ($uptime = $not){
# If not running, the program then executes the below, else do nothing
$run = `cp /home/x`;
$start = `start`;
}