Luis Cano Luis Cano - 5 months ago 45
R Question

invoking system commands from shiny app

I am trying to call a system command from my shiny app:

system("ssh -t soporte@xx.yy.zz.xx /home/soporte/Automatismos/ user password", wait = TRUE)

What I want to do is to run a bash script in another machine through SSH. Well, I tested the system call from the R console logged as shiny user (as I read these system calls are run as shiny user) and it perfectly works. But then when I tried from the shiny app doesn't work. I also checked the user permissions and so on.

The script code is:

#Activamos el proxy de polen
echo "Levantando el proxy a Internet...."
sudo /root/bin/ up $1 $2
export http_proxy=
export https_proxy=
rm -f /srv/shinyapps/proyectosR/Web/csv_report_manager3.csv
#Actualizamos el CSV atando la API de UDO
echo "Descargando CSV..."
curl -u user:password --insecure -X GET "$(date +"%Y-%m-%d" -d "-1 year")T00:00:00.000Z&date_end=$(date +"%Y-%m-%d" -d "-1 day")T23:59:00.999Z&service=CS_GLOBNOC" > /srv/shinyapps/proyectosR/Web/csv_report_manager3.csv

#Resfrescamos el servidor shiny
echo "Refrescando servidor shiny..."
sudo kill -9 $(ps ax | grep proyectosR | fgrep -v grep | awk '{ print $1 }')

#Desactivamos proxy de Polen
echo "Cerrando proxy...."
sudo /root/bin/ down $1 $2

What I do in this script is to open a proxy then I downloaded a CSV file, refresh the shiny server and then close the connection. When it fails I get a empty CSV file.

I captured the exit code in both cases, through the console I get 0 code which means the script was correctly executed and through shiny app I get 1, which is not correct.

Note that the shiny server machine is a docker container (Ubuntu) and the machine where I need to run the script is the host machine (CentOS).

I tried to search for documentation about this topic but I couldn't find much information on the Internet.

Would be possible to debug the shiny app somehow in order to find what is failing?

Any help would be appreciated. Thank you in advance

Answer Source

It seems it was a permissions issue. It is already solved. Thanks!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download