Sponsored Content
Top Forums Shell Programming and Scripting Access Awk Variables Outside Scope Post 302094236 by jim mcnamara on Thursday 26th of October 2006 07:16:55 AM
Old 10-26-2006
This is clunky but will work:
Add this one last line in the END section:
Code:
printf ("FAIL=%d\nSUCCESS=%d\nTOTAL=%d",totalfailrecs,totalsuccessrecs,totalrecs)>"temp.sh"

in your shell script
Code:
chmod +x ./temp.sh
. ./temp.sh

This will "import" three variables: FAIL SUCCESS TOTAL
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Access Awk Variables Outside Scope

Sorry in the wrong forum. Moving this to right forum. (2 Replies)
Discussion started by: Amruta Pitkar
2 Replies

2. Shell Programming and Scripting

How to access variables across scripts

Hi All, I have declared a variable in script1 and assign a value for it. In script2 i'll call script1 and then I want the value of variables set in script1. I have tried with export, but in vain. How can I achive this? Below is the two scripts. --script1 #!/usr/bin/ksh echo $1... (1 Reply)
Discussion started by: javaDev
1 Replies

3. Shell Programming and Scripting

Doubt??? [scope of variables]

Heres an example..... <~/abc>$ cat textfile line 1 line 2 line 3 line 4 line 5 <~/abc>$ cat try.sh #/bin/ksh for runs in 1 2 3 do A=$runs echo "Inside A : $A" done echo "Outside A : $A" <- works fine (1 Reply)
Discussion started by: qzv2jm
1 Replies

4. Shell Programming and Scripting

how to access values of awk/nawk variables outside the awk/nawk block?

i'm new to shell scripting and have a problem please help me in the script i have a nawk block which has a variable count nawk{ . . . count=count+1 print count } now i want to access the value of the count variable outside the awk block,like.. s=`expr count / m` (m is... (5 Replies)
Discussion started by: saniya
5 Replies

5. Shell Programming and Scripting

Access variables from profile file

Hi all, I hav created one profile file in which i have declared some variables i want to knw how can i access these variables into my xyz.ksh file when i am trying to do " echo $variablename " its giving me an empty line i have done export variable also in the profile file. Thanks in... (6 Replies)
Discussion started by: navi
6 Replies

6. Shell Programming and Scripting

Doubt about variables scope

I call my script with two parameters myscript.sh aaa bbb What is the way to access $1 and $2 values inside a function? I call the function like this myfuntion $1 $1 but inside of the function, $1 and $2 are empty. Any suggestions? thank you in advanced. (1 Reply)
Discussion started by: aristegui
1 Replies

7. Shell Programming and Scripting

Variables scope.

Hi , I'm trying to change the variable value in a while loop , however its not working it seems that the problem with subshells while reading the file. #!/bin/sh FLAG=0; cat filename | while read data do FLAG=1; done echo $FLAG Should display 1 instead displays 0 (13 Replies)
Discussion started by: dinjo_jo
13 Replies

8. Shell Programming and Scripting

while read loop; scope of variables (shell)

If I set a variable within a while-read loop, sometimes it's local to the loop, sometimes it's global, depending on how the loop is set up. I'm testing this on a Debian Lenny system using both bash and dash with the same results. For example: # Pipe command into while-read loop count= ls -1... (2 Replies)
Discussion started by: mjd_tech
2 Replies

9. Shell Programming and Scripting

Scope of variables between scripts

Friends, I am using ksh under SunoS. This is what I have In file1.sh NOW=$(date +"%b-%d-%y") LOGFILE="./log-$NOW.log" I will be using this file through file1.sh as log file. I have another script file2.sh which is being called inside my file1.sh. I would like to use the same log... (6 Replies)
Discussion started by: dahlia84
6 Replies

10. Programming

Regarding the protected variables access

Hello forum, I am siva working as programmer .I was blocked with the below issue so please help any of the forum memebers. testve.h class cv { protected : struct state; state& m_state; }; testVe.cpp struct state { m_size; } the above are 2 files which have the... (3 Replies)
Discussion started by: workforsiva
3 Replies
JE::Scope(3pm)						User Contributed Perl Documentation					    JE::Scope(3pm)

NAME
JE::Scope - JavaScript scope chain (what makes closures work) DESCRIPTION
JavaScript code runs within an execution context which has a scope chain associated with it. This class implements this scope chain. When a variable is accessed the objects in the scope chain are searched till the variable is found. A JE::Scope object can also be used as global (JE) object. Any methods it does not understand will be delegated to the object at the bottom of the stack (the far end of the chain), so that "$scope->null" means the same thing as "$scope->[0]->null". Objects of this class consist of a reference to an array, the elements of which are the objects in the chain (the first element being the global object). (Think of it as a stack.) METHODS
find_var($name, $value) find_var($name) This method searches through the scope chain, starting at the end of the array, until it finds the variable named by the first argument. If the second argument is present, it sets the variable. It then returns an lvalue (a JE::LValue object) that references the variable. new_var($name, $value) new_var($name) This method creates (and optionally sets the value of) a new variable in the variable object (the same thing that JavaScript's "var" keyword does) and returns an lvalue. The variable object is the first object in the scope chain (searching from the top of the stack) that is a call object, or "$scope->[0]" if no call object is found. CONSTRUCTOR
None. Just bless an array reference. You should not need to do this because it is done for you by the "JE" and "JE::Object::Function" classes. SEE ALSO
JE JE::LValue JE::Object::Function perl v5.14.2 2012-03-18 JE::Scope(3pm)
All times are GMT -4. The time now is 12:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy