Skip to content

Tag: shell

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…

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 …

struggling with a shell script in linux

I am trying to create a script that takes two arguments, source folder and target folder. I am trying to show an error message if the source directory is not found and exit the program. If target directory is not found, I would like it to create that directory. Then I would like to copy all the contents from …

Running a script in terminal using Linux

Im trying to run this script in the terminal but its not working and says permission denied. scriptEmail is filename. scriptEmail is written as follows: My read write permission Answer As for permissions: Check that your shebang is at the very top of your file, and that it starts exactly with #!; # ! will not…

How to execute sh command set in shell variable?

I have this linux command: candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2> /dev/null > /tmp/can.log & It works correctly when I run it directly in shell. I want to add it in my script with this method: When I execute my script I get this error: SIOCGIFINDEX: No such device I have tested these scrip…

Shebang option ‘ #!/bin/csh -f ‘

What does the Shebang option -f do? How do I find, or man, detailed explanations on all Shebang options? Answer There aren’t any “shebang options”. Any options there are options to the binary in the shebang. So that’s a csh option. Specifically (from the man page): -f The shell will st…