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?

ラズパイからnode.jsでPC起動 2号機

Last updated at Posted at 2024-12-03

1.etherwakeでラズパイからPC起動に成功しました。以下で問題無
https://qiita.com/m_sunafukin77/items/50a055ae0c99dfb8b6f8

2.node.jsのコマンド変わっている。
ていうか 導入の仕方が違う? 動けばいいか。
参考サイトから 導入しなおす。 バージョンは最新にしてから実施すること。
https://zenn.dev/jun_eg/articles/b9b38239dfb841

sudo apt-get install -y nodejs

以下のコマンドでバージョンが表示

node -v

3.それでは etherwakeのjsを作って動かしてみる。

sudo vim etherwake.js

内容は以下 これで2台のPC(Windows、Linux Mint)が立ち上がる。

const exec1 = require('child_process').exec;
exec1('sudo etherwake xx:xx:xx:xx:xx:xx', (err, stdout, stderr) =>{
  if (err) { console.log(err); }
  console.log(stdout);
});

const exec2 = require('child_process').exec;
exec2('sudo etherwake xx:xx:xx:xx:xx:xx', (err, stdout, stderr) => {
  if (err) { console.log(err); }
  console.log(stdout);
});

4.パスの確認

which node
which npm

5.実行

sudo node etherwake.js

6.ちなみにパスの全体確認は以下

echo $PATH

7.パスの追加は

export PATH=”$PATH:/home/pi”

8.全体を置き換える場合は。 

export path="/home/pi/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
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?