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 …
Tag: bash
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…
Glob that doesn’t match anything expands to itself, rather than to nothing
I want to iterate over the files in a folder of a special type (like .test): So I wrote a little script names for_loop: After (chmod +x for_loop) I can start it with ./for_loop. If there are .test-files, everthing is fine, BUT if there is no file in the folder that matches *.test, the for-loop is still execut…
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 …
Why does my command fail when I check port occupancy? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …
How to store linux command output into a variable in puppet
Is it possible to store a linux command result in variable? I am trying to store an encrypted value in a variable. To encrypt I am using base64 command. To store it in variable, I am using generate method. But I am not able to store a value. Answer If you want to execute any command on Puppet Master server
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:
Writing Bash Script to Log Out if Incorrect upon Login. Need guidance
I am trying to write a Bash Script that will log the user out if they cannot get the security question. I am needing to find either an array or multiple if conditions to reflect this. I know there are a lot of sub-stuff such as stopping any override input(CTRL+Z, etc). Below is the script I have so far, and
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…