so here is my problem: I have a pc that i use mainly through ssh and i recently created a telegram bot to quickly perform those commands used more frequently.
It works fine except for the shutdown command.
$connection = ssh2_connect('www.example.com', 22);
ssh2_auth_password($connection, 'user', 'mypass');
$stream = ssh2_exec($connection, 'netstat | grep ESTABLISHED || shutdown -P now');
I use this code since i need to verify nobody else (my brother) is connected to the pc before shutting it down, but it looks like that regardless the output of netstat | grep ESTABLISHED
the code || shutdown -P now
is always gettin executed.
I always used such a code through ssh to verify the connection and it has always work'd fine. how can i have || shutdown -P now
part executed only if the output of netstat | grep ESTABLISHED
is empty?