I am trying to call a system command from my shiny app:
system("ssh -t soporte@xx.yy.zz.xx /home/soporte/Automatismos/refrescar_csv.sh 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:
#!/bin/bash
#Activamos el proxy de polen
echo "Levantando el proxy a Internet...."
sudo /root/bin/proxy2blaster.sh up $1 $2
export http_proxy=http://127.0.0.1:3128
export https_proxy=https://127.0.0.1:3128
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 "https://www.udo-tt.com/api/tt/reports/csv/ticketsbyservice?date_start=$(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/proxy2blaster.sh 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
It seems it was a permissions issue. It is already solved. Thanks!