Wording the title was a little tricky, but here’s the situation. I am making a install.sh file for my game which is written in Python. I am trying to create a game folder with all assets instead of making this a module for Python. I may be doing things the hard way, but this method seems to work well. T…
Tag: bash
Why does SetSUID not work for shell script?
I am trying to create a executor program for regular users on linux with SUID bit set so whatever commands, passed to the program as parameters, get executed with root permission. However when I try to implement this as a bash script, this does not work, where it works when implemented in C. I want to know wh…
How to select the nth char from a string for each line in a file?
Every line has a word and a number. I need somehow to select the nth letter which all together will make a new word. For example: it has to start like this and I’m only allowed to use sed (no awk, perl, …). I know how to select all the numbers or the text and I was thinking about but
Use terminal to display image without losing focus
I have a bash-script in which I want to display an image to the user. This is possible using ImageMagick’s display. But now the focus of the terminal window is lost, and is placed to the image. To continue my bash-script I have to ask the user to click on the terminal before continuing. This is unwanted…
How to read a file line by line
I try to read a file line by line. File to read: Script: When I execute the script, this window will be opened: (Notice how some values are repeated, and the contents don’t correctly alternate between names and versions): I’d like to create an array with all package names and versions. Answer You …
SSH – Entering a Passphrase Only Once
On $ ssh localhost, I was being asked to provide password. It was tedious and kind of annoying to provide password for every login. So, I have created ssh keys with passphrase.. I have copied the content of the ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys Now, on $ ssh localhost I was being asked to provide pa…
bash: Possible to require double Ctrl-c to to exit a script?
End-goal: BASH script that is waiting for background jobs to finish does not abort on first Ctrl-c; instead, it requires a second Ctrl-c to quit. I’m well aware of how the BASH-builtin trap works. You can either: Use it to ignore a signal altogether (e.g., trap ” 2) … or Use it to have arbit…
How can I make a hybrid bash/tcsh script on Linux?
I have one script which runs in Bash and and other which runs in tcsh. I need to run them both from the same script. How can I create a script that can run both bash and tcsh commands? Answer Most shells have an argument which allow you to pass them a string to run as a command, for example,
ImageMagick using convert and rename output
I a directory I have several files name like 13992.jpg 13993.jpg 13994.jpg 13995.jpg … How do I rename these files using convert? I have tried but it is not working… Any suggestions? Answer you probably want to run convert in a loop, like consider also this little “trick” for renaming:
Check if a condition is false
It is seems to be an easy question, I wonder why googling didn’t give anything helpful — nor in StackOverflow, nor in tutorials. I just need to check using bash that a condition is false. Of what I found I tried and none of them print Hello. I found only two similar questions, but the end answer i…