1654: "Universal Install Script"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

User avatar
glasnt
Posts: 539
Joined: Fri Jan 25, 2008 5:18 am UTC
Location: SQUEE!

1654: "Universal Install Script"

Postby glasnt » Fri Mar 11, 2016 5:14 am UTC

Image

Alt:The failures usually don't hurt anything, and if it installs several versions, it increases the chance that one of them is right. (Note: The 'yes' command and '2>/dev/null' are recommended additions.)



Code: Select all

gem install "$1" &
composer install "$1" &
...


TLDR: Please don't actually use this code.

TranquilFury
Posts: 131
Joined: Thu Oct 15, 2009 1:24 am UTC

Re: 1654: "Universal Install Script"

Postby TranquilFury » Fri Mar 11, 2016 5:19 am UTC

How do I install my keyboard?

Brian-M
Posts: 85
Joined: Tue Jan 18, 2011 6:31 am UTC

Re: 1654: "Universal Install Script"

Postby Brian-M » Fri Mar 11, 2016 5:26 am UTC

Code: Select all

The program 'pip' is currently not installed. You can install it by typing:
sudo apt-get install python-pip
No command 'easy-install' found, did you mean:
 Command 'easy_install' from package 'python-setuptools' (main)
easy-install: command not found
No command 'brew' found, did you mean:
 Command 'brec' from package 'bplay' (universe)
 Command 'qbrew' from package 'qbrew' (universe)
The program 'npm' is currently not installed. You can install it by typing:
sudo apt-get install npm
The program 'yum' is currently not installed. You can install it by typing:
sudo apt-get install yum
The program 'docker' is currently not installed. You can install it by typing:
sudo apt-get install docker.io
No command 'pkg' found, did you mean:
 Command 'pki' from package 'pki-tools' (universe)
 Command 'pki' from package 'strongswan-starter' (main)
 Command 'pig' from package 'bsdgames' (universe)
 Command 'pg' from package 'util-linux' (main)
 Command 'dpkg' from package 'dpkg' (main)
 Command 'ekg' from package 'ekg-gtk' (universe)
 Command 'ekg' from package 'ekg' (universe)
 Command 'peg' from package 'peg' (universe)
pkg: command not found
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
[sudo] password for Brian-M:
Sorry, try again.
steamcmd: command not found
The program 'git' is currently not installed. You can install it by typing:
sudo apt-get install git
bash: No such file or directory

:wink:

Spoiler:
I didn't actually run the script. I mostly just typed in the names of the programs with nothing after them, not even "install", and copy-pasted the results. With a few changes, such as replacing my user-name with my forum name

rajington
Posts: 1
Joined: Fri Mar 11, 2016 5:25 am UTC

Re: 1654: "Universal Install Script"

Postby rajington » Fri Mar 11, 2016 5:27 am UTC

I put the script on github under universalinstallscript/universalinstallscript, but I can't link it without being marked as spam :(

User avatar
Eternal Density
Posts: 5559
Joined: Thu Oct 02, 2008 12:37 am UTC
Contact:

Re: 1654: "Universall Instal Script"

Postby Eternal Density » Fri Mar 11, 2016 6:02 am UTC

Usually I have to python3.5 -m pip install --user

TranquilFury wrote:How do I install my keyboard?

Ask a zookeeper.
Play the game of Time! castle.chirpingmustard.com Hotdog Vending Supplier But what is this?
In the Marvel vs. DC film-making war, we're all winners.

LockeZ
Posts: 51
Joined: Mon Jan 19, 2009 8:30 am UTC

Re: 1654: "Universal Install Script"

Postby LockeZ » Fri Mar 11, 2016 6:20 am UTC

oops no funny

User avatar
Solra Bizna
Posts: 55
Joined: Fri Dec 04, 2015 6:44 pm UTC

Re: 1654: "Universal Install Script"

Postby Solra Bizna » Fri Mar 11, 2016 6:21 am UTC

Without parentheses, the second-to-last line doesn't do what Randall wants.

User avatar
vodka.cobra
Posts: 371
Joined: Thu Mar 27, 2008 6:50 pm UTC
Location: Florida
Contact:

Re: 1654: "Universal Install Script"

Postby vodka.cobra » Fri Mar 11, 2016 6:40 am UTC

The alt-text is wrong. If you put something really dumb in $1 then curl | bash can lead to your computer being taken over (requires an active attacker with control over your DNS responses and/or a man in the middle). So, yes, that does hurt something.

User: "Oh, I need this shared library. ./install.sh somethingsilly.so"

Curl: "Hmm, .so is a legit TLD, I should make an HTTP request"

Attacker: "Nah, return `cat "someEd25519publicKey" > ~/.ssh/authorized_keys` instead."

So basically what I'm saying here is laugh at the funny comic but DO NOT TREAT IT AS ADVICE. From your neighborhood computer security nerd.
If the above comment has anything to do with hacking or cryptography, note that I work for a PHP security company and might know what I'm talking about.

User avatar
Flumble
Yes Man
Posts: 2082
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: 1654: "Universal Install Script"

Postby Flumble » Fri Mar 11, 2016 7:16 am UTC

I take it Arch is a rare distro? Since none of the methods (well, except cd-ing and running make —assuming you've setup the system with base-devel) work out of the box.

User avatar
sfmans
Posts: 104
Joined: Mon Jun 23, 2014 9:09 am UTC
Location: High Peak, UK

Re: 1654: "Universal Install Script"

Postby sfmans » Fri Mar 11, 2016 7:54 am UTC

Such fun: proving the truth of http://xkcd.com/927/ once again.

User avatar
Reecer6
Posts: 100
Joined: Fri Nov 30, 2012 12:59 am UTC

Re: 1654: "Universal Install Script"

Postby Reecer6 » Fri Mar 11, 2016 9:45 am UTC

I don't think this shell script accounts for the fact that none of these things will help me download the OS I will use to download them on, and I'm kind of stuck at ground zero.

User avatar
cellocgw
Posts: 1956
Joined: Sat Jun 21, 2008 7:40 pm UTC

Re: 1654: "Universal Install Script"

Postby cellocgw » Fri Mar 11, 2016 12:23 pm UTC

INB4 : Hey this only works if you have a *nix shell running in the first place!

Anyone else here old enough to have thought the

Code: Select all

 pip install
was referring to this?

Anyway, "install" is where horses should be.
https://app.box.com/witthoftresume
Former OTTer
Vote cellocgw for President 2020. #ScienceintheWhiteHouse http://cellocgw.wordpress.com
"The Planck length is 3.81779e-33 picas." -- keithl
" Earth weighs almost exactly π milliJupiters" -- what-if #146, note 7

User avatar
sfmans
Posts: 104
Joined: Mon Jun 23, 2014 9:09 am UTC
Location: High Peak, UK

Re: 1654: "Universal Install Script"

Postby sfmans » Fri Mar 11, 2016 12:31 pm UTC

Reecer6 wrote:I don't think this shell script accounts for the fact that none of these things will help me download the OS I will use to download them on, and I'm kind of stuck at ground zero.


I've just spent a few happy minutes musing on what, er, distinctive features an xkcd distro would have ...

crdoconnor
Posts: 1
Joined: Fri Mar 11, 2016 12:25 pm UTC

Re: 1654: "Universal Install Script"

Postby crdoconnor » Fri Mar 11, 2016 12:36 pm UTC

I created an app that basically does this. pip install unixpackage from pypi.

User avatar
cellocgw
Posts: 1956
Joined: Sat Jun 21, 2008 7:40 pm UTC

Re: 1654: "Universal Install Script"

Postby cellocgw » Fri Mar 11, 2016 1:28 pm UTC

sfmans wrote:
Reecer6 wrote:I don't think this shell script accounts for the fact that none of these things will help me download the OS I will use to download them on, and I'm kind of stuck at ground zero.


I've just spent a few happy minutes musing on what, er, distinctive features an xkcd distro would have ...


Well, I can guarantee it'd be entirely in 16-bit format, i.e. no "long words" :mrgreen:
https://app.box.com/witthoftresume
Former OTTer
Vote cellocgw for President 2020. #ScienceintheWhiteHouse http://cellocgw.wordpress.com
"The Planck length is 3.81779e-33 picas." -- keithl
" Earth weighs almost exactly π milliJupiters" -- what-if #146, note 7

User avatar
jc
Posts: 349
Joined: Fri May 04, 2007 5:48 pm UTC
Location: Waltham, Massachusetts, USA, Earth, Solar System, Milky Way Galaxy
Contact:

Re: 1654: "Universal Install Script"

Postby jc » Fri Mar 11, 2016 1:32 pm UTC

Solra Bizna wrote:Without parentheses, the second-to-last line doesn't do what Randall wants.

Yeah; I noticed that. And surrounding it with an "if" (using your favorite shell's syntax) works even better, since it minimizes the jumble of error messages when things don't exist.

A quick check on a friendly nearby linux box found apt, apt-get, arch, curl and install. I wonder what'd happen if I pit them all against each other. Would there be a consistent winner? And would the results generally be usable after all the race conditions sorted themselves out?

fdd1_s3nt
Posts: 1
Joined: Fri Mar 11, 2016 1:46 pm UTC

Re: 1654: "Universal Install Script"

Postby fdd1_s3nt » Fri Mar 11, 2016 1:50 pm UTC

Would it be better to use

Code: Select all

||
instead of

Code: Select all

&
to eliminate the duplicate install problem?

Also, he can probably make this safer by checking if each command exists before trying to run them.

User avatar
Keyman
Posts: 311
Joined: Thu Jun 19, 2014 1:56 pm UTC

Re: 1654: "Universal Install Script"

Postby Keyman » Fri Mar 11, 2016 1:52 pm UTC

Don't suppose there's any way to explain this to those of us who's last 'programming' experience was on punch tape? :oops:

EDIT:
Sorry. I forgot. http://www.explainxkcd.com/wiki/index.php/1654

It's because I'm dumb.
Nothing could be more ill-judged than that intolerant spirit which has, at all times, characterized political parties. - A. Hamilton

svchost
Posts: 1
Joined: Fri Mar 11, 2016 2:45 pm UTC

Re: 1654: "Universal Install Script"

Postby svchost » Fri Mar 11, 2016 2:47 pm UTC

The real question is: Where is zypper?

atlas29
Posts: 2
Joined: Tue Oct 01, 2013 6:53 pm UTC

Re: 1654: "Universal Install Script"

Postby atlas29 » Fri Mar 11, 2016 3:09 pm UTC

I was sad not to see

Code: Select all

gem install $1 &
cpanm $1 &

User avatar
Soupspoon
You have done something you shouldn't. Or are about to.
Posts: 3726
Joined: Thu Jan 28, 2016 7:00 pm UTC
Location: 53-1

Re: 1654: "Universal Install Script"

Postby Soupspoon » Fri Mar 11, 2016 4:14 pm UTC

jc wrote:A quick check on a friendly nearby linux box found apt, apt-get, arch, curl and install. I wonder what'd happen if I pit them all against each other. Would there be a consistent winner?


Very likely something written in/for RedCode...

Zinho
Posts: 101
Joined: Fri Apr 08, 2011 3:23 pm UTC

Re: 1654: "Universal Install Script"

Postby Zinho » Fri Mar 11, 2016 4:49 pm UTC

If Randall were more patient he could use && instead of & and the commands would be launched serially instead of in parallel. Not as much fun as watching all those background commands dumping their output in a jumbled heap to STDOUT, but the first one to return success (0 = false) would short-circuit the evaluation and skip all the following steps.

I gotta give Randall props, though, for distilling the Three Virtues (Laziness, Impatience, Hubris) and crystallizing them in code form so nicely for us :D

*EDIT*
Been too long since I did any Bash scripting; apparently && interprets 0 as true when concatenating commands, and using it like I suggested would halt after the first non-zero (false) result. You'd want to use || to make an OR list instead. Carry on...

User avatar
ManaUser
Posts: 284
Joined: Mon Jun 09, 2008 9:28 pm UTC

Re: 1654: "Universal Install Script"

Postby ManaUser » Fri Mar 11, 2016 5:22 pm UTC

TranquilFury wrote:How do I install my keyboard?

Plug it in and type install self.

Justin Lardinois
Posts: 47
Joined: Wed Aug 26, 2015 4:47 pm UTC

Re: 1654: "Universal Install Script"

Postby Justin Lardinois » Fri Mar 11, 2016 5:40 pm UTC

vodka.cobra wrote:The alt-text is wrong. If you put something really dumb in $1 then curl | bash can lead to your computer being taken over (requires an active attacker with control over your DNS responses and/or a man in the middle). So, yes, that does hurt something.

User: "Oh, I need this shared library. ./install.sh somethingsilly.so"

Curl: "Hmm, .so is a legit TLD, I should make an HTTP request"

Attacker: "Nah, return `cat "someEd25519publicKey" > ~/.ssh/authorized_keys` instead."

So basically what I'm saying here is laugh at the funny comic but DO NOT TREAT IT AS ADVICE. From your neighborhood computer security nerd.


Image

The fact that it's harmful and he's saying it's not is the joke.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: 1654: "Universal Install Script"

Postby PM 2Ring » Fri Mar 11, 2016 6:25 pm UTC

cellocgw wrote:INB4 : Hey this only works if you have a *nix shell running in the first place!

Anyone else here old enough to have thought the

Code: Select all

 pip install
was referring to this?

Anyway, "install" is where horses should be.


I'm old enough to have used pip on CP/M, and I was certainly reminded of that pip when I first started using the modern pip to install Python stuff. But no, this comic didn't make me think of the old pip until you mentioned it.

typo
Posts: 32
Joined: Wed Jun 16, 2010 4:12 pm UTC
Location: East of the Don and west of the Rouge

Re: 1654: "Universal Install Script"

Postby typo » Fri Mar 11, 2016 6:35 pm UTC

cellocgw wrote:Anyone else here old enough to have thought the

Code: Select all

 pip install
was referring to this?

Yes. Yes, I did. I first encountered PIP on RSX-11D circa 1974, and later on 'M and early VMS.

I typed PIP to a VMS DCL prompt, to see if it was still lurking, and was quite surprised to receive a response. Turned out it wasn't running the Peripheral Interchange Programme, though. Instead it took PIP as an appreviation for the PIPE command, which simulates pipe and other syntax from UNIX shell. Neat-o.

WyomingPBS
Posts: 8
Joined: Fri May 29, 2009 3:16 pm UTC

Re: 1654: "Universal Install Script"

Postby WyomingPBS » Fri Mar 11, 2016 7:04 pm UTC

Flumble wrote:I take it Arch is a rare distro? Since none of the methods (well, except cd-ing and running make —assuming you've setup the system with base-devel) work out of the box.


Not just arch; several distros use pacman. Just adding

Code: Select all

pacman -S "$1" &

somewhere in the middle would take care of that.

vkuzkokov
Posts: 4
Joined: Fri Jan 14, 2011 9:48 am UTC

Re: 1654: "Universal Install Script"

Postby vkuzkokov » Fri Mar 11, 2016 7:37 pm UTC

Why no emerge?

freetringers
Posts: 1
Joined: Fri Mar 11, 2016 9:14 pm UTC

Re: 1654: "Universal Install Script"

Postby freetringers » Fri Mar 11, 2016 9:18 pm UTC

What's missing here is Intercal.

User avatar
Solra Bizna
Posts: 55
Joined: Fri Dec 04, 2015 6:44 pm UTC

Re: 1654: "Universal Install Script"

Postby Solra Bizna » Sat Mar 12, 2016 12:07 am UTC

vkuzkokov wrote:Why no emerge?

The idea is to include only commands that have a chance of working. ;)

(Sorry, my last Gentoo experience was right in the middle of the expat fiasco...)

xtifr
Posts: 336
Joined: Wed Oct 01, 2008 6:38 pm UTC

Re: 1654: "Universal Install Script"

Postby xtifr » Sat Mar 12, 2016 2:28 am UTC

At least one bug in this script. The ampersand after the git line doesn't belong there, and should be replaced with a semicolon. (Or with nothing, since a newline has basically the same effect.) The git part merely downloads the source; the next line is what builds and installs the app.

Also, that whole stretch of commands starting with git (or with cd if you don't make the change suggested above) needs to be put into parens, with the ampersand outside the parens, so that a failure in any of the earlier commands won't make the whole rest of the script fail and halt. Otherwise, the curl command will likely never execute. (Although, given that that's the only really dangerous command in the whole sequence, perhaps that's a feature not a bug?)
"[T]he author has followed the usual practice of contemporary books on graph theory, namely to use words that are similar but not identical to the terms used in other books on graph theory."
-- Donald Knuth, The Art of Computer Programming, Vol I, 3rd ed.

User avatar
Solra Bizna
Posts: 55
Joined: Fri Dec 04, 2015 6:44 pm UTC

Re: 1654: "Universal Install Script"

Postby Solra Bizna » Sat Mar 12, 2016 5:25 am UTC

Actually, without `set -e` it will chug forward in spite of any command failures.

xtifr
Posts: 336
Joined: Wed Oct 01, 2008 6:38 pm UTC

Re: 1654: "Universal Install Script"

Postby xtifr » Sat Mar 12, 2016 9:59 am UTC

Solra Bizna wrote:Actually, without `set -e` it will chug forward in spite of any command failures.

Oh that's right. Nevertheless, if you want all these tasks to run in parallel, you want the surrounding parentheses. Otherwise the whole thing will be tied up until the "make" command either succeeds or fails. Then the "make install" will go into the background, and only then will the curl command start.

Not strictly a bug (unlike the problem with the git command), but not optimal or consistent performance.
"[T]he author has followed the usual practice of contemporary books on graph theory, namely to use words that are similar but not identical to the terms used in other books on graph theory."
-- Donald Knuth, The Art of Computer Programming, Vol I, 3rd ed.

Lucia
Posts: 95
Joined: Sun May 09, 2010 1:35 am UTC

Re: 1654: "Universal Install Script"

Postby Lucia » Sat Mar 12, 2016 10:01 am UTC

I thought the point was the script tries to bribe people $1 to install the script for you.
Actually, I like that version better. :lol:
Wildhound wrote:Nobody ever sigs me. I think it's because I never say anything clever.

ps.02
Posts: 378
Joined: Fri Apr 05, 2013 8:02 pm UTC

Re: 1654: "Universal Install Script"

Postby ps.02 » Sat Mar 12, 2016 10:31 am UTC

Lucia wrote:I thought the point was the script tries to bribe people $1 to install the script for you.
Actually, I like that version better. :lol:

Yeah but notice the scare quotes around the $1 each time. I think that means it's a Canadian dollar.

Lucia
Posts: 95
Joined: Sun May 09, 2010 1:35 am UTC

Re: 1654: "Universal Install Script"

Postby Lucia » Sat Mar 12, 2016 10:53 am UTC

Why would you need to bribe a Canadian to help you?
Wildhound wrote:Nobody ever sigs me. I think it's because I never say anything clever.

rmsgrey
Posts: 3480
Joined: Wed Nov 16, 2011 6:35 pm UTC

Re: 1654: "Universal Install Script"

Postby rmsgrey » Sat Mar 12, 2016 1:10 pm UTC

Lucia wrote:Why would you need to bribe a Canadian to help you?


An attempt at bribery is evidence that the person thought a bribe was needed, not that it actually was.

User avatar
ucim
Posts: 6588
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: 1654: "Universal Install Script"

Postby ucim » Sat Mar 12, 2016 4:01 pm UTC

Well, if it's a Canadian, you'd have to use Canadian conversational rules, eh?

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Please help addams if you can. She needs all of us.

User avatar
MarkGyver
Posts: 35
Joined: Sun Nov 09, 2008 6:56 am UTC

Re: 1654: "Universal Install Script"

Postby MarkGyver » Sat Mar 12, 2016 11:05 pm UTC

I currently boot into 3 different distros on a semi-regular basis: Chakra (originally Arch-based, still using Pacman), openSUSE, and Kubuntu. I got tired of the problem this strip's script (allegedly) addresses and wrote a script that checks which distro's package manager is available and runs the appropriate command for package search, install, info, remove, and upgrade, gracefully exiting if no supported package managers are found.

Now I'm tempted to add support for detecting if the package was actually found by the package manager, and if not then proceed with safer versions of everything here that I actually use, possibly even installing the relevant "package manager"-like programs as-needed....

Flumble wrote:I take it Arch is a rare distro? Since none of the methods (well, except cd-ing and running make —assuming you've setup the system with base-devel) work out of the box.

vkuzkokov wrote:Why no emerge?

svchost wrote:The real question is: Where is zypper?

Running "pm install package" with my script installed will correctly run whichever of pacman, zypper, or apt-get you have installed and use it to install "package". If you submit a bug report or pull request with public domain code (either written by you or explicitly placed in the public domain by its author) to add your favorite package manager (e.g., emerge), I'll gladly add the improvement to the script.
Generation 0: The first time you see this, copy it into your signature and change it so that it looks like you inspired this signature. Social experiment.

Sandor
Posts: 177
Joined: Sat Feb 13, 2010 8:25 am UTC

Re: 1654: "Universal Install Script"

Postby Sandor » Sat Mar 12, 2016 11:26 pm UTC

svchost wrote:The real question is: Where is zypper?

Or "rpm --install"?

Writing a bash script and giving it a ".sh" extension as if it were a Bourne script always strikes me as slightly wrong. I do it anyway, because ".bash" as a file extension seems wronger, although I don't know why (too many characters?)


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: jc and 40 guests