0

Hi I am trying to run the bash command in shell script but couldn't completely figure out how as I have very minimal knowledge with Linux/Unix.

Here is the command :

bash <(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh) '1.0.0'

I am able to execute the command in shell without the version like this:

/bin/bash -c "$(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh)"

but if I try to pass the version like this:

/bin/bash -c "$(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh) '1.0.0'"

or

/bin/bash -c "$(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh '1.0.0')"

it won't execute the command. Can someone help me with this

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
  • 1
    so why not use `bash <(...)`? `help me with this` Help with what exactly? The first command should have worked, did you try it? Why not, if you're having trouble, just download the file, save it, and run it then? The `bash <(...)` _is_ a shell command. – KamilCuk Mar 26 '21 at 16:12
  • 3
    What are you trying to do, try to put that in words. –  Mar 26 '21 at 16:15
  • 1
    I am trying to execute the bash <(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh) '1.0.0' in aws device farm yaml file but it throws an syntax error at ( – Shilpa kodali Mar 26 '21 at 16:21
  • 1
    bash <(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh) '1.0.0' should work. What is the error exactly? – Raman Sailopal Mar 26 '21 at 16:24
  • 1
    It's a _bash_ command, not a `#!/bin/sh` command. Which specific shell you're using matters. `sh yourscript` will fail if yourscript has this code, but `bash yourscript` will work fine. – Charles Duffy Mar 26 '21 at 16:40
  • Please don't change any questions in ways that invalidate existing answers. – Baum mit Augen Apr 19 '21 at 21:30

1 Answers1

0

This command will do the same thing though, try this out-

curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh | bash -s '1.0.0'

curl downloads this script from online, and as the download finishes the file will be run by bash and bash will pass the argument '1.0.0' to it to download this specific version of XCTestHTMLReport (it is default to version 1.6.1).

Or you could simply create a script file on your computer with this, and run it to do the same thing.

#!/bin/bash

set -e

VERSION=$1

if [ -z $VERSION ] ; then
VERSION="1.0.0"
fi

OUT_ZIP="xchtmlreport.zip"

printf "Downloading xchtmlreport $VERSION\n"


CURL=$(curl -L -s -w "%{http_code}" -o $OUT_ZIP https://github.com/TitouanVanBelle/XCTestHTMLReport/releases/download/$VERSION/xchtmlreport-$VERSION.zip)

if [ ! -f $OUT_PATH ]; then
  printf '\e[1;31m%-6s\e[m' "Failed to download XCTestHTMLReport. Make sure the version you're trying to download exists."
  printf '\n'
  exit 1
fi

unzip $OUT_ZIP

chmod 755 xchtmlreport
mv xchtmlreport /usr/local/bin/

rm $OUT_ZIP

printf '\e[1;32m%-6s\e[m' "Successully installed XCTestHTMLReport. Execute xchtmlreport -h for help."
printf '\n'
exit 0

I did a slight modification as I changed the default version to 1.0.0.

Naimul Kabir
  • 434
  • 6
  • 13