Note that there are some explanatory texts on larger screens.

plurals
  1. POBash does not continue execution
    primarykey
    data
    text
    <p>I am parsing the result of an extracted string. My problem is the execution stops after the first element was processed. </p> <p>Here is my code:</p> <pre><code>#!/bin/bash SCAN_RESULT=$(arp-scan --ignoredups --interface=$1 --localnet) HEADER_REMOVED=$(echo "$SCAN_RESULT" | sed '1,2d') NO_HEADER_LINE_COUNT=$(echo "$HEADER_REMOVED" | wc -l) CAPTURED_DEVICE_INFO=$(echo "$HEADER_REMOVED" | sed $(expr $NO_HEADER_LINE_COUNT - 2),"$NO_HEADER_LINE_COUNT"d) DATA=$(echo "$CAPTURED_DEVICE_INFO" | sed 's/[\t]/;/g') DATA_LINE_COUNT=$(echo "$DATA" | wc -l) echo -n '[' for ((i=0; i&lt;$DATA_LINE_COUNT; i++)) # stops execution after 1st cycle do EXTRACTED_DATA=$(echo "$DATA" | sed $(expr "$i" + 1)'!d') echo -n '{' COMMA_INNER='' for i in {1..3} do echo -n "$COMMA_INNER" case $i in 1) echo -n '"ip":' ;; 2) echo -n '"mac":' ;; 3) echo -n '"manufacturer":' ;; esac echo -n '"' echo -n $(echo $EXTRACTED_DATA | cut -d ';' -f$i) echo -n '"' COMMA_INNER=',' done echo -n '}' done echo -n ']' </code></pre> <p>This is the output string from the arp-scan:</p> <pre><code>Interface: eth0, datalink type: EN10MB (Ethernet) Starting arp-scan 1.8.1 with 16 hosts (http://www.nta-monitor.com/tools/arp-scan/) 192.168.0.1 20:aa:4b:c0:22:78 (Unknown) 192.168.0.5 48:5b:39:a0:60:ba ASUSTek COMPUTER INC. 192.168.0.7 04:7d:7b:7d:c4:e9 (Unknown) 5 packets received by filter, 0 packets dropped by kernel Ending arp-scan 1.8.1: 16 hosts scanned in 0.819 seconds (19.54 hosts/sec). 3 responded </code></pre> <p>This is the string(from arp-scan) I would like to be processed and echoed as JSON</p> <pre><code>192.168.0.1 20:aa:4b:c0:22:78 (Unknown) 192.168.0.5 48:5b:39:a0:60:ba ASUSTek COMPUTER INC. 192.168.0.7 04:7d:7b:7d:c4:e9 (Unknown) </code></pre> <p>Here is the sample output:</p> <pre><code>[{"ip":"192.168.0.1","mac":"20:aa:4b:c0:22:78","manufacturer":"(Unknown)"}] </code></pre> <p>Am I doing it wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload