0
Hello I am trying to create a script that reads my file take all the variable it needs then use it for another command. But it seems that the variables are not being memorized, because I tried a printf instead of running my script and I got an empty output.
here is my code
#!/bin/bash
numparams=$#
params=$*
cat tots.txt | while read;
do awk '{
regid=$1;
uport=$2;
ongoingcalls=$3;
ingeg=$4;
maxcalls=$5;
if($3<$5) state=0
if($3==$5) state=1
if($3>$5) state=2
}'
/home/send_script.sh -o "$regid $uport $ongoingcalls $ingeg $maxcalls $state"
done
And here is the tots.txt content:
And by "the variables are not being memorized", you mean exactly what? – Run CMD – 2015-12-11T10:23:28.837
so for example if afte the awk command I type printf "$regid" it will give me nothing. – Peter Hayek – 2015-12-11T10:24:54.633
Well,
awk
variables are notbash
variables. You would need to assign the result ofawk
tobash
variables. But you don't needawk
at all in this case. I'd just usebash
features. – Run CMD – 2015-12-11T10:30:14.223Play around with 1)
test
aka[]
to setstate
and 2) the following snippet:while read line; do set $line; echo $1 $2 $3 $4; done
and you'll get where you want. – Run CMD – 2015-12-11T10:34:11.213