He creado un bash script para iniciar un ordenador de red si está durmiendo, y luego iniciar un cliente de streaming. Sin embargo, cuando el script ejecuta el comando final para ejecutar el cliente de streaming, cada opción de cli con un guión se envuelve en $'\342\200\224<option>'
. Por ejemplo -resolution
se convierte en $'\342\200\224resolution'
.
En concreto, este comando en el script:
/Applications/Moonlight.app/Contents/MacOS/Moonlight stream "$_target_computer_ip" "$_moonlight_app_name" —resolution "$_moonlight_resolution" —fps "$_moonlight_fps" &>/dev/null &
se ejecuta en el shell como:
/Applications/Moonlight.app/Contents/MacOS/Moonlight stream 192.168.1.30 mstsc.exe $'\342\200\224resolution' 1920x1024 $'\342\200\224fps' 30
He intentado escapar el guión como -, pero eso sólo cambia la salida a $'?\200\224
. ¿Qué estoy haciendo mal?
Aquí está el script completo:
#!/bin/bash
set -x
_target_computer_ip='192.168.1.30'
_target_computer_subnet='192.168.1.255'
_target_computer_mac='2C:F0:5D:27:7C:95'
_moonlight_app_name='mstsc.exe'
_moonlight_resolution='1920x1080'
_moonlight_fps='30'
if ping -c 1 -W 1 "$_target_computer_ip"; then
echo "is alive"
else
echo "nope"
wakeonlan -i $_target_computer_subnet $_target_computer_mac
fi
/Applications/Moonlight.app/Contents/MacOS/Moonlight stream "$_target_computer_ip" "$_moonlight_app_name" —resolution "$_moonlight_resolution" —fps "$_moonlight_fps" &>/dev/null &
Y la salida completa del comando:
Fayes-MBP:Shell Scripts rain$ ./check_and_wake_pc.sh
+ _target_computer_ip=192.168.1.30
+ _target_computer_subnet=192.168.1.255
+ _target_computer_mac=2C:F0:5D:27:7C:95
+ _moonlight_app_name=mstsc.exe
+ _moonlight_resolution=1920x1080
+ _moonlight_fps=30
+ echo 192.168.1.30
192.168.1.30
+ ping -c 1 -W 1 192.168.1.30
PING 192.168.1.30 (192.168.1.30): 56 data bytes
--- 192.168.1.30 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss, 1 packets out of wait time
round-trip min/avg/max/stddev = 3.701/3.701/3.701/0.000 ms
+ echo 'is alive'
is alive
+ /Applications/Moonlight.app/Contents/MacOS/Moonlight stream 192.168.1.30 mstsc.exe $'?\200\224resolution' 1920x1080 $'?\200\224fps' 30