[Edit - Save your time. Better rendering of the situation at this entry]
I've got a script with a shebang that works on Ubuntu Mate, but not on Lubuntu Minimal (+LXDE).
I can't quite get what I need from searches, and I'm now overwhelmed.
My first (ever!) script, written on my host Ubuntu Mate (xenial) machine, worked beautifully easily. That version is at the end of this post.
I took the same script to my VM Lubuntu Minimal machine, (rewrote it manually - no sharing), and ran into trouble.
In Lubuntu Minimal I've tried the following shebangs, gleaned from various forums:
#!/bin/bash
works fine in the host
#!/bin/sh
#!/usr/bin/env bash
which yield (mostly):
bash: /home/user/bin/script1: [the path part of the shebang, e.g./bin/bash/]: bad interpreter: not a directory
I've restarted the machine once or twice, and used chmod +x
and chmod 700
- checking with 'ls -l' shows the same permissions as the working version on Ubuntu Mate.
I've tried naming the script script1.sh
as well as just script1
. I've called it using /.script1
and /.script1.sh
, to no result. (I don't know what these /.
and sh
exactly do, nor for what process).
I've placed the script file in:
/usr/local/bin
(which I think I had to create, from memory)
~/Desktop
just to see
~/bin
(and I did indeed have to create this)
Some forum talked about $PATH
and rebooting, so I've rebooted a couple of times (but I don't understand $PATH
).
The only (partial) success comes from removing the shebang and saving that script in ~/bin
.
Two problems:
I just can't understand why. What critical thing is missing from Lubuntu Minimal that Ubuntu Mate has? If I just create, say a `/bin/bash' directory, will bash magically find its way there, do nothing, or will I break it?
Ultimately, I want this to run from a
.desktop
launcher, but initial experiments fail - usingExec=script1
in the desktop entry makes a terminal window flash up then close, instantly. Previously I've usedbash -c "cmd1 && cmd2 &&..."
in Lubuntu, but bash is throwing an error here. Intuitively, I guess that's because I removed 'bash' from the shebang, but see problem 1., above.
My head is now pretty tangled, and I'm not sure where to start reading to get on top of this. Your wisdom would be appreciated.
Thanks in advance
Original test script (works in Ubuntu Mate):
#!/bin/bash
#host to block
echo -e "enter domain to block:"
read host_name
host_entry="127.0.1.1\t$host_name"
echo -e $host_entry >>/home/user/Desktop/host-edits-test
echo "***done and gone***"
sleep 2
exit 0
/bin/bash
exist in Lubuntu? And!#
is not the correct syntax, the correct one is#!
– Romeo Ninov Dec 14 '17 at 09:08#!/bin/bash
-- (without the final bar) – JJoao Dec 14 '17 at 09:08chmod u+rx
it. Also read wikipage on PATH (variable). You might perhaps need to edit some file like your~/.bashrc
to permanently change it for interactive shells, but YMMV – Basile Starynkevitch Dec 14 '17 at 09:31