At Monday, 10 September 2001, Robert Heffernan wrote:
>>>> This one works ok:
>> pppstats | sed 1d | awk '{print $1" "$7"\n"}'
>> the sed bit strips the line that contains the heards (such as 'IN',
>> 'OUT' etc.) from it
>>>> I have another short question. Is there a way to stick the output
>> of said command into a variable
This is normally done by enclosing the command sequence in grave accents
("backticks"), eg
FOO=`pppstats | sed 1d | awk '{print $1" "$7"\n"}'`
>> and then return the said variable to the child
>> process of the srript.
export FOO
>> I'm actually running this script from a C program (using system()).
Should still work provided the child is called directly from the
parent script. If control returns to the C program first, you'd
have to pass the value of FOO back to the program (by making the
script output it and writing the call to system() in such a way
that it expected a string return. Then pass FOO to the child as
a variable.
///Peter
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!