I wrote a script that deactivates all the interfaces available using nmcli commands such as: I would now like to reactivate these interfaces; there is no nmcli dev connect iface … command, and I’m stuck. In particular, my problem is to reactivate the Ethernet interface. Thanks in advance for your help! Answer Use this command: You can also use uuid
Tag: sh
In Unix, how to display welcome message if user has logged in from a particular IP (or host)?
I want to display one message if user XYZ has logged in from any IP (or host). Answer Check to see if you have environment variables such as SSH_CLIENT and SSH_CONNECTION set. If so, you can access these from scripts (perl, bash, etc…) to dynamically generate a welcome message. Below, is a simple perl script to extract the IP address
Read line output in a shell script
I want to run a program (when executed it produces logdata) out of a shell script and write the output into a text file. I failed to do so :/ $prog is the executed prog -> socat /dev/ttyUSB0,b9600 STDOUT $log/$FILE is just path to a .txt file I had a Perl script to do this: I tried to do this
How to append entry the end of a multi-line entry using any of stream editors like sed or awk
I am trying to use a script to append the host name at the end of a multi-line entry of a specific Host_Alias field in sudoers file. The current sudoers file has an entry similar to : My required output would be something like the following where I have added “,host25” There are more lines before and after this segment.
Validating file records shell script
I have a file with content as follows and want to validate the content as 1.I have entries of rec$NUM and this field should be repeated 7 times only. for example I have rec1.any_attribute this rec1 should come only 7 times in whole file. 2.I need validating script for this. If records for rec$NUM are less than 7 or Greater
How can I make a chgrp command optional in my install script?
I’m creating an install script for a Linux game. As part of the installation, I change the suid permissions of the game executable to the “games” group so that the game can update the highscore file even when its run by regular users. Right now my Makefile.am looks like this: The problem I am having is that the chgrp command
How can I look up a variable by name with #!/bin/sh (POSIX sh)?
What shell command should I use so that echo $c returns “filename1” as the output? Answer You can use eval to “nest” variable substitutions.
Arrays in Shell Script, not Bash
I am probably just having a brain fart, but I can not for the life of me figure out how to loop through an array in shell script, not bash. Im sure the answer is on stackoverflow somewhere already, but I can not find a method of doing so without using bash. For my embedded target system bash is not
How to cat <> a file containing code?
I want to print code into a file using cat <<EOF >>: but when I check the file output, I get this: I tried putting single quotes but the output also carries the single quotes with it. How can I avoid this issue? Answer You only need a minimal change; single-quote the here-document delimiter after <<. or equivalently backslash-escape it:
Shell script: Run function from script over ssh
Is there any clever way to run a local Bash function on a remote host over ssh? For example: Yeah, I know it doesn’t work, but is there a way to achieve this? Answer You can use the typeset command to make your functions available on a remote machine via ssh. There are several options depending on how you want