Re: Modifying the environment variables of a parent process
Hi Markhazy,
first I guess this isn't the right place, but well, the damage is done :)
TLTR;
you have a cdiv code that gives in output two numbers, real and the imaginary part
you want to store them into bash variables.
so, why can't you do a simple bash script for doing this?
I see a trivial solution: get the return of the cvid program and store in a temp variable.
then split it.
user@user:-$ A=-1
user@user:-$ B=6
"cdiv $A 5 $B 0"
-0.16667 + j0.8333
so I would do something like
TEMP=`cdiv $A 5 $B 0`
or
TEMP=$(cdiv $A 5 $B 0)
note the special "`" character
AC=$(echo $TEMP | cut -d "+" -f 1)
ACIM=$(echo $TEMP | cut -d "+" -f 2)
if you want to strip the j
ACIM=$(echo $TEMP | cut -d "+" -f 2 | cut -d "j" -f 2)
man cut
man echo
can help you :)
(of course this is a bad solution, a nicer solution might be to save the output in a file and parte is,
directly use some bash command to calculate that, e.g. some bc scripting [1] or even make your cdiv communicate with sockets, dbus or just by printing
output on more lines, to avoid the need to parse the output with bash)
[1] http://phodd.net/gnu-bc/code/complex.bc
HTH, even if I'm not sure I understood the question.
cheers,
G.
Reply to: