curl
HTTP get リクエストを使用してサーバーからホスト名をプルするために使用しましたが、それは正常に機能しています。/etc/sysconfig/network
ホスト名を適用するためにシステムを再起動する必要がないように、ファイルを変更するにはスクリプトが必要です。
これまでの私のコードは次のとおりです。
#!/usr/local/bin/perl
use strict;
use warnings;
use Sys::Hostname;
my $curl = `curl http://100.10.10.10/hostname`; # Get correct hostname
my $host = hostname;
if ($curl ne $host) {
# Need to modify the /etc/sysconfig/network file to replace hostname or add it.
}
編集: 私の実際の質問: 新しいホスト名でそのファイルを変更するための最良の方法は何ですか?