jayjr
1
first time poster here but I have ocasionally dipped my toes into linux from time to time. This one for whatever reason has me pulling out what little hair i have left.
I have installed the latest ubuntu and have everything working great so far. I wanted to have a script that would launch mame along with a game which i wanted to then launch at startup. I installed mame via the snap directory and got everything running fine. I created a shell script with simply:
#!/usr/bin/bash
mame pacman
I proceeded to give it using chmod +x command and execute the script as a program. When i do i receive the following error: failed to execute child process /home/jay/snap/mame/pacman.sh": failed to execve : no such file or directory.
I’ve read just about every article i could about creating scripts and watched at least 3 youtube videos. I then decided to try the same but launching firefox and receive the same error. There’s gotta be something I’m doing wrong here but can’t figure out what. The commands work perfectly if i type them out in a terminal.
Any help you could give me would be greatly appreciated.
The script is fine — the problem is the very first line.
#!/usr/bin/bash
There is no /usr/bin/bash
on Ubuntu (bash lives in /bin/bash
).
So when you mark the file executable and double-click it, the kernel tries to
run /usr/bin/bash …
and throws “No such file or directory”.
Fix in two minutes
Open the file and change the she-bang to either of these:
#!/bin/bash # absolute path
#--- or, more portable ---
#!/usr/bin/env bash
Make sure the file has Unix line endings (LF, not CRLF).
If you edited it in Windows, run dos2unix pacman.sh
.
Keep it executable:
chmod +x pacman.sh
Test:
./pacman.sh # should launch MAME Pac-Man now
Starting it automatically
Create a small .desktop file in ~/.config/autostart/
:
[Desktop Entry]
Type=Application
Name=Pac-Man
Exec=/home/jay/snap/mame/pacman.sh
X-GNOME-Autostart-enabled=true
Save - log out / log in - Pac-Man fires up on its own.
That’s all there is to it wrong path in the she-bang was the only gotcha. Enjoy the game!
2 Likes
ogra
3
Well, if you do not actually use any bash specific functions (like variable arrays and whatnot) and do not want to load a 5MB shell binary into RAM just for running a small script you should even switch this to /bin/sh
which links to dash
in Ubuntu and debian, it will act faster and is only a few kilobyte big … this will even be more portable in the end
3 Likes
Shouldn’t it be the other way round since UsrMerge? And with UsrMerge /bin
should be a symbolic link to /usr/bin
. As far as I understand this both should work.
I once tried to start apps through a bash script and did it using bash -c 'command'
inside the script. Perhaps this works for you, too.
#!/usr/bin/bash
bash -c 'mame pacman'
I recommend using the full path to all binaries just to remove ambiguity
1 Like