Files
scripts/legacy/pc_runner.sh
2026-01-17 09:10:20 +00:00

27 lines
677 B
Bash
Executable File

#!/bin/bash
# Bash Script To Power On PC and SSH into it.
MAC_ADDRESS="00:d8:61:c5:e8:69"
USER="zaine"
IP="192.168.0.135"
echo "Hang tight..."
# Call wakeonlan and capture the output
OUTPUT=$(wakeonlan "$MAC_ADDRESS" 2>&1) # 2>&1 captures both stdout and stderr
echo "wakeonlan output: $OUTPUT"
# Analyze the output (simple example)
if [[ $OUTPUT == *"Sending magic packet"* ]]; then
echo "Wake-on-LAN packet sent successfully."
else
echo "Error sending magic packet or no response: $OUTPUT"
fi
# Sleep for 15 seconds so that the PC can wake up
sleep 45
echo "Attempting to SSH into $USER@$IP..."
# Start SSH and let it take over the terminal
ssh -X "$USER@$IP"