#!/bin/bash
# Helper script to run commands on r630-01 with password
# Usage: ./run-with-password.sh "command"

PASSWORD="L@kers2010"
HOST="root@192.168.11.11"

if [ -z "$1" ]; then
    echo "Usage: $0 'command'"
    exit 1
fi

# Try sshpass first
if command -v sshpass &> /dev/null; then
    sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$HOST" "$1"
# Try expect
elif command -v expect &> /dev/null; then
    expect << EOF
spawn ssh -o StrictHostKeyChecking=no "$HOST" "$1"
expect "password:"
send "$PASSWORD\r"
expect eof
EOF
else
    echo "Error: sshpass or expect not found. Please install one:"
    echo "  sudo apt install sshpass"
    echo "  OR"
    echo "  sudo apt install expect"
    exit 1
fi


