ラベル centos の投稿を表示しています。 すべての投稿を表示
ラベル centos の投稿を表示しています。 すべての投稿を表示

2015年4月3日金曜日

shell上での並列処理


シェルでのジョブの並列実行 sleepを同時起動し、待ち合わせを行う

sleep 10 &
pid_0=$!
sleep 10 &
pid_1=$!

wait $pid_0
wait $pid_1


シェルでのジョブの並列実行の繰り返し sleepを同時起動し、待ち合わせを行うことを10回繰り返す
for i in `seq 1 10`
do
  echo $i
  sleep 10 &
  pid_0=$!
  sleep 10 &
  pid_1=$!
 
  wait $pid_0
  wait $pid_1
 
done


2015年3月26日木曜日

centosからwindowsにリモートログインし、コマンド実行



# wget http://sourceforge.net/projects/winexe/files/latest/download
# tar zxvf winexe-1.00.tar.gz
# cd winexe-1.00/source4/
# ./autogen.sh
# ./configure
# make
# make install

例)centosからwindowsにログインし、vbscriptを実行
$ /usr/local/samba/bin/winexe -U WINUSER%WINPASSWORD //SERVER "cmd.exe /C cd C:\WORKDIR & cscript WORK.vbs" | iconv -f SJIS -t UTF-8



sshでパスワード自動入力

# wget http://sourceforge.net/projects/sshpass/files/latest/download
# tar zxvf sshpass-1.05.tar.gz
# cd sshpass-1.05
# ./configure
# make
# make install

例)sshで別サーバーのプロセス取得
$ sshpass -pPASSWORD ssh USER@SERVER ps ax
例)ファイル転送
$ sshpass -pPASSWORD scp -o StrictHostKeyChecking=no /tmp/test.txt USER@SERVER:/tmp/

/home/USER/.bash_profileに下記追加
alias sshpass='/usr/local/bin/sshpass -pPASSWORD ssh '

使用例)
$ sshpass SERVER