I have a script that looks like:
curl -sSL outagebuddy.com/path/linux_installer | bash -s
Users can install a linux client for the site using the command that is provided to them. I'm thinking there should be an intermediary step that verifies the curl had a 2XX response and downloaded the content successfully before passing it to bash. How can I do that?
Without a user-managed temporary file:
if script=$(curl --fail -sSL "$url"); then
bash -s <<<"$script"
fi
If you don't mind having an intermediate file (which you certainly need if you want to make sure the curl command worked fully) then you can use:
if curl --fail -sSL <params> -o script.sh
then
bash script.sh
fi
OS: Ubuntu 14.04
I am trying to install RVM as multi user from a shell script, I have the following in the shell script:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
sudo curl -L https://get.rvm.io | bash -s stable
When I run the script, I get the following:
Installing RVM to /home/ubuntu/.rvm/
When I'm expexting to see:
Installing RVM to /usr/local/rvm
The advice on stackoverflow is to install it as sudo, but this is not working. Any ideas?
You have sudo on the wrong half of the command.
You need it on the bash half not the curl half.
You want a sudo-ed shell not a sudo-ed download.
curl -L https://get.rvm.io | sudo bash -s stable
rvm installer uses curl to install rvm. Copy from rvm official website, the command is
curl -L https://get.rvm.io | bash -s stable --autolibs=enabled [--ruby] [--rails] [--trace].
Getting the idea from this, I want to create an auto-installer using curl as well. This is my installer script fetch.sh:
#!/usr/bin/env bash
# Copyright Ciel 2014
FLAG=$#
echo 'FLAG has been set to -ns '$FLAG
git clone --recursive https://github.com/imwithye/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
./install.sh $FLAG
And I try to install my program via \curl -sSL http://dot.ciel.im | bash $FLAG(http://dot.ciel.im points to my fetch.sh script). As you can see, I want to pass the args $FLAG from curl command to fetch.sh script, but it failed.
Does anyone know how can I pass the args from curl command *** | bash $FLAG to the installer script?
What you want is :
echo "$(curl -sSL http://dot.ciel.im)" | bash -s FLAG1 FLAG2 etc
The echo with quotes is important for not being interpreted as a single line. Then, the bash -s allows you to add arguments to the script bash is executing.
you can also add -x to debug and see what commands are called and with which parameters.
echo "$(curl -sSL http://dot.ciel.im)" | bash -x -s FLAG1 FLAG2 etc
After I installed rvm using the following command in my Fedora 12 system:
\curl -L https://get.rvm.io | bash -s stable –ruby
When I want to use rvm, it says
rvm: command not found
I want to use rvm for: rvm install 1.9.3
What is the solution.
Your command uses an en-dash ('–', U+2013):
\curl -L https://get.rvm.io | bash -s stable –ruby
but the installation instructions at https://rvm.io/rvm/install/ use a double ASCII dash, '--':
\curl -L https://get.rvm.io | bash -s stable --ruby
Really, I don't know what happened. Excuse me if this question is so NOOB, but I can't find the solution for this problem.
-bash: rvm: command not found
I tried this
curl -L https://get.rvm.io | bash -s -- --version latest
but still nothing I need to see the ruby version for use the simplecov because it not works with older version from 1.9
It might because the terminal not having rvm shell configuration loaded.
Try following from your terminal:
$ source ~/.rvm/scripts/rvm
then
$ type rvm | head -n 1
If the output is:
rvm is a function
You may need to add "source ~/.rvm/scripts/rvm" to your ~/.bash_profile file
you need to read all the texts that are displayed when you install RVM:
rm -rf ~/.rvm
curl -L https://get.rvm.io | bash -s stable
after you run sudo curl -L https://get.rvm.io | bash -s stable --ruby
you need to close the terminal ,then open again!
This worked for me:
rm -rf ~/.rvm
curl -L https://get.rvm.io | bash -s stable
source /etc/profile worked for me.
For a long-term solution, you should add this to your ~/.profile file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
to simply load rvm into a single terminal, use
source "$HOME/.rvm/scripts/rvm"
supposedly this call is more cross-platform:
. "$HOME/.rvm/scripts/rvm"
As suggested by #mpapis, Do this first
$ rm -rf ~/.rvm
$ curl -L https://get.rvm.io | bash -s stable
Then, as suggested by #peterpengnz, do this and you should be fine with RVM cmd issues
$ source ~/.rvm/scripts/rvm
Close and restart terminal after installing RVM — gets me EVERY TIME.
To start using RVM, you'll need to enter source /Users/yourusername/.rvm/scripts/rvm into your terminal (of course, insert your real username in place of yourusername).
Close and reopen your terminal. Sometimes, the changes made during the installation of rvm are not immediately picked up by your terminal, so reopening it should resolve the problem.