Skip to content

Tag: bash

bash hiding default stderr code and replacing it with my own

When I use ping foo.com I either get a response or ping: unknown host foo.com I am using this script to show custom responses the problem with the above is that, if site is found I get site found response, but if not instead of the error message, I get the default ping: unknown host foo.com UPDATED. . Answer …

sed removes one string in one file

I’m trying to remove one string in one file by using: But I’ve got the following error: What is it missing and why? Thanks! Answer /example/ is an address which tells sed where to run commands – on a line containing the string example. You didn’t specify any commands. This is a commnan…

passing bash array to python list

I’m trying to pass an array from bash to python using the old getenv method however I keep getting this error: could someone please explain why the $mdcNo isn’t passing from bash to python successfully? Code .sh: code .py: Answer If you want to pass a shell array to the Python script, your best be…

Shell Script file access

I have written a shell script on my mac. Following code: The problem is that the program wlalink gives me an error message: LOAD_FILES: Could not open file “temp.prj”. It seems that there are problems with some rights. The script is creating a file and there is the right content in the file. Same …

how to customize select loop in bash

I was wondering if is possible customize the select loop for bash. I have this code: Output is something like this: I would like to order the options in landscape view and also change the prompt [#?] by something else Thanks Answer select displays the PS3 prompt. You could try something like:

Attempting to pass Linux command output into a variable

I have the following code: With the following output: As you can see, gpio pin 123 is set to ‘in’ and 124 is set to ‘out’. However, both gp123 and gp124 are being assigned ‘in’. I am rusty with functions and C. Could you fellas help me out a little please? More specifically…