0

I can run this line by line on a fresh ubuntu 16.04 instance in Digital Ocean but I when I give it executable permissions chmod +x and run it I get failed attempts at running different parts of the script.

sudo apt-get -y install nginx git libcurl4-gnutls-dev libxml2-dev libssl-dev 
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get install r-base r-base-dev gdebi-core
sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.us.r-project.org')\""
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.us.r-project.org')\""
sudo su - -c "R -e \"install.packages('XML', repos='http://cran.us.r-project.org')\""
(crontab -l 2>/dev/null; echo "5 0 * * * Rscript /root/transit-tracker/scripts_in_testing/download_gtfs.R ") | crontab -
(crontab -l 2>/dev/null; echo "* * * * * Rscript /root/transit-tracker/scripts_in_testing/get_tidy_gps.R ") | crontab -
wget https://download3.rstudio.org/ubuntu-12.04/x86_64/shiny-server-1.5.3.838-amd64.deb
sudo gdebi -n shiny-server-1.5.3.838-amd64.deb 
sudo sed -i 's/  listen 3838;/  listen 80;/' /etc/shiny-server/shiny-server.conf
# then reboot 

In response I get;

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package
Executing: /tmp/tmp.EeBdzAP95F/gpg.1.sh --keyserver
keyserver.ubuntu.com
--recv-keys
E298A3A825C0D65DFD57CBB651716619E084DAB9
" not a key ID: skipping57CBB651716619E084DAB9
E: Invalid operation update
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package r-base
E: Unable to locate package r-base-dev
E: Unable to locate package gdebi-core
-su: R: command not found
-su: R: command not found
-su: R: command not found
-su: R: command not found
-su: R: command not found
'rontab: invalid option -- '
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -e | -l | -r }
                (default operation is replace, per 1003.2)
        -e      (edit user's crontab)
        -l      (list user's crontab)
        -r      (delete user's crontab)
        -i      (prompt before deleting user's crontab)
'rontab: invalid option -- '
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -e | -l | -r }
                (default operation is replace, per 1003.2)
        -e      (edit user's crontab)
        -l      (list user's crontab)
        -r      (delete user's crontab)
        -i      (prompt before deleting user's crontab)
--2017-05-08 22:39:38--  https://download3.rstudio.org/ubuntu-12.04/x86_64/shiny-server-1.5.3.838-amd64.deb%0D
Resolving download3.rstudio.org (download3.rstudio.org)... 52.85.90.213, 52.85.90.39, 52.85.90.98, ...
Connecting to download3.rstudio.org (download3.rstudio.org)|52.85.90.213|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-05-08 22:39:38 ERROR 404: Not Found.

sudo: gdebi: command not found
: No such file or directoryserver/shiny-server.conf
2

As you confirmed in the comments, your script has been written on a Windows system and contains Windows-style (CR+LF) line endings instead of Unix-style (LF), which would be necessary.

To easily convert the line endings of text files between DOS/Windows and Unix style, install a package named dos2unix:

sudo apt install dos2unix

It comes with two commands, dos2unix to convert a Windows text file to Unix format, and unix2dos to convert a Unix text file to Windows format.

In your case, simply run

dos2unix FILENAME

replacing FILENAME with your actual script file name, and it should run fine after that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.