Skip to content
Advertisement

Tag: sh

Programatically activate and deactivate network interfaces using nmcli

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

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

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

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

Advertisement