Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Request: Advice from a Scripting expert desired
-
- Posts: 485
- Joined: 2009-07-04 06:32
- Location: Home: Barrackpore and Mysore
- Has thanked: 5 times
Request: Advice from a Scripting expert desired
This is the request: Advice from a Scripting expert desired
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home
-
- Posts: 485
- Joined: 2009-07-04 06:32
- Location: Home: Barrackpore and Mysore
- Has thanked: 5 times
Re: Request: Advice from a Scripting expert desired
I found the following resources:
(1) https://unix.stackexchange.com/question ... ron-reboot
(2) https://www.gnu.org/software/gawk/manua ... ement.html
(3) http://thomas-cokelaer.info/blog/2011/0 ... substring/
(4) https://stackoverflow.com/questions/970 ... ell-script
(5) https://stackoverflow.com/questions/112 ... turn-value
(6) https://unix.stackexchange.com/question ... urn-status
(7) https://www.linuxquestions.org/question ... ll-297495/
"... /etc/rc.local ... on a Debian system with SysV (not systemd): rc.local was (almost) the last service to start ..."
"cron, as a task scheduler, is intended as a method to perform maintenance or upkeep to a machine, such as checking updates, cleaning caches, or performing security audits. This doesn't mean that it is limited to performing those functions, as it can run any script or command desired at the specified time (such as @reboot)"
I need to run a bash script writing the following flowchart:
First,
2nd, the redirect the output to a string variable.
3rd, use awk to read the 3rd character, i.e., digit. Check if the value is 'digit' and is 5.
Wait for 1 minute, i.e., pause 60.
Loop to step 2nd if isn't "5" or the exit code of runlevel and awk aren't "0".
4th Step: execute the command,. Check the exit code. If it is not 0 then again go to 4th step.
5th Step: execute and transfer to output to a string variable; and the exit code to another integer variable.
6th Step: If output string doesn't contain the string "Loopback PCM", or the exit code is not 0, Loop back to step 4th. Else, ending.
Perhaps I would be told that Stackexchange Unix/Linux would have been a better place for such queries. But learners have no place there. Greeted by Negative rankings and n. Then one is barred from posting.
You could also suggest linuxquestions.org. Well, I will, if you all fail to address my concerns. But I need to provide you with opportunity to help. I have two experimental scripts and a text file for experimentation, copied from the posters at the stackexchange.
=========================================== code.sh ===========================================
#!/bin/bash
SOURCE_PATH=input.txt
VERSION=$(awk '/Id=[0-9]*.[0-9]*/ {print $0}' "$SOURCE_PATH")
echo "Version line : $VERSION"
=========================================== sc.sh ===========================================
#! /bin/bash
RuleNum=$1
gawk -v var=$RuleNum '$1==var {for(i = NF; i >= 0; i--) if ($i ~ /bps/) {sub("bps","",$i); sub("BW.*:", "", $i); out = out delim $i; delim = OFS} print out; out = delim = ""}' input.txt
=========================================== input.txt ===========================================
20 name:abc addr:203.45.247.247/255.255.255.255 WDW-THRESH:12 BW-OUT:10000000bps BW-IN:15000000bps STATSDEVICE:test247 STATS:Enabled (4447794/0) <IN OUT>
25 name:xyz160 addr:203.45.233.160/255.255.255.224 STATSDEVICE:test160 STATS:Enabled priority:pass-thru (1223803328/0) <IN OUT>
37 name:testgrp2 <B> WDW-THRESH:8 BW-BOTH:192000bps STATSDEVICE:econetgrp2 STATS:Enabled (0/0) <Group> START:NNNNNNN-255-0 STOP:NNNNNNN-255-0
62 name:blahblahl54 addr:203.45.225.54/255.255.255.255 WDW-THRESH:5 BWLINK:cbb256 BW-BOTH:256000bps STATSDEVICE:hellol54 STATS:Enabled (346918/77) <IN OUT>
=========================================== Ending ===========================================
I shall continue to experiment. Just need some help.
(1) https://unix.stackexchange.com/question ... ron-reboot
(2) https://www.gnu.org/software/gawk/manua ... ement.html
(3) http://thomas-cokelaer.info/blog/2011/0 ... substring/
(4) https://stackoverflow.com/questions/970 ... ell-script
(5) https://stackoverflow.com/questions/112 ... turn-value
(6) https://unix.stackexchange.com/question ... urn-status
(7) https://www.linuxquestions.org/question ... ll-297495/
"... /etc/rc.local ... on a Debian system with SysV (not systemd): rc.local was (almost) the last service to start ..."
"cron, as a task scheduler, is intended as a method to perform maintenance or upkeep to a machine, such as checking updates, cleaning caches, or performing security audits. This doesn't mean that it is limited to performing those functions, as it can run any script or command desired at the specified time (such as @reboot)"
I need to run a bash script writing the following flowchart:
First,
Code: Select all
runlevel
Code: Select all
N 5
3rd, use awk to read the 3rd character, i.e., digit. Check if the value is 'digit' and is 5.
Wait for 1 minute, i.e., pause 60.
Loop to step 2nd if isn't "5" or the exit code of runlevel and awk aren't "0".
4th Step: execute the command,
Code: Select all
sudo modprobe snd-aloop
5th Step: execute
Code: Select all
sudo aplay -l
6th Step: If output string doesn't contain the string "Loopback PCM", or the exit code is not 0, Loop back to step 4th. Else, ending.
Perhaps I would be told that Stackexchange Unix/Linux would have been a better place for such queries. But learners have no place there. Greeted by Negative rankings and n. Then one is barred from posting.
You could also suggest linuxquestions.org. Well, I will, if you all fail to address my concerns. But I need to provide you with opportunity to help. I have two experimental scripts and a text file for experimentation, copied from the posters at the stackexchange.
=========================================== code.sh ===========================================
#!/bin/bash
SOURCE_PATH=input.txt
VERSION=$(awk '/Id=[0-9]*.[0-9]*/ {print $0}' "$SOURCE_PATH")
echo "Version line : $VERSION"
=========================================== sc.sh ===========================================
#! /bin/bash
RuleNum=$1
gawk -v var=$RuleNum '$1==var {for(i = NF; i >= 0; i--) if ($i ~ /bps/) {sub("bps","",$i); sub("BW.*:", "", $i); out = out delim $i; delim = OFS} print out; out = delim = ""}' input.txt
=========================================== input.txt ===========================================
20 name:abc addr:203.45.247.247/255.255.255.255 WDW-THRESH:12 BW-OUT:10000000bps BW-IN:15000000bps STATSDEVICE:test247 STATS:Enabled (4447794/0) <IN OUT>
25 name:xyz160 addr:203.45.233.160/255.255.255.224 STATSDEVICE:test160 STATS:Enabled priority:pass-thru (1223803328/0) <IN OUT>
37 name:testgrp2 <B> WDW-THRESH:8 BW-BOTH:192000bps STATSDEVICE:econetgrp2 STATS:Enabled (0/0) <Group> START:NNNNNNN-255-0 STOP:NNNNNNN-255-0
62 name:blahblahl54 addr:203.45.225.54/255.255.255.255 WDW-THRESH:5 BWLINK:cbb256 BW-BOTH:256000bps STATSDEVICE:hellol54 STATS:Enabled (346918/77) <IN OUT>
=========================================== Ending ===========================================
I shall continue to experiment. Just need some help.
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home