Garayed.com  

Go Back   Garayed.com > Linux
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-12-2006, 06:54 PM
Unruh
 
Posts: n/a
Default Re: awk: importing and exporting variables

opexoc@gmail.com writes:

>Hi. I was trying to write script which will be do something when
>program called kadu is executed. It is this script ( or some prototype
>of this script ):


>-------------------------------------------
>#!/bin/bash
>export var=0
>ps aux | awk '/[k]adu/ { ENVIRON["var"]++ } END{ print ENVIRON["var"]
>}'


What is this line supposed to do? What is ENVIRON["var"]++ supposed to do?
What is will do is to read the value of the var variable ( more easily done
by '$var' ) and incriment that read value. It does nothing to the value of
var.
Rather than use this script just do
if ps aux|grep -v grep|grep '[k]adi'>/dev/null ; then
Run your command
fi


>echo $var
>if [ $var = "1" ]
>then
> echo "1"
>else
> echo "0"
>fi


>-------------------------------------------


>My main problem is to import content of variable "var" from awk. I
>thought that when I will use "export" command and I make "var" some
>global variable it will works, but it didn't. How can you help me ?


>best regards,
>opexoc


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:00 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.