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
MAXDB_STMT_RESULT_METADATA(3)						 1					     MAXDB_STMT_RESULT_METADATA(3)

maxdb_stmt_result_metadata - Returns result set metadata from a prepared statement

       Procedural style

SYNOPSIS
resource maxdb_stmt_result_metadata (resource $stmt) DESCRIPTION
Object oriented style resource maxdb_stmt::result_metadata (void ) If a statement passed to maxdb_prepare(3) is one that produces a result set, maxdb_stmt_result_metadata(3) returns the result resource that can be used to process the meta information such as total number of fields and individual field information. Note This result set pointer can be passed as an argument to any of the field-based functions that process result set metadata, such as: omaxdb_num_fields(3) omaxdb_fetch_field(3) omaxdb_fetch_field_direct(3) omaxdb_fetch_fields(3) omaxdb_field_count(3) omaxdb_field_seek(3) omaxdb_field_tell(3) omaxdb_free_result(3) The result set structure should be freed when you are done with it, which you can do by passing it to maxdb_free_result(3) Note The result set returned by maxdb_stmt_result_metadata(3) contains only metadata. It does not contain any row results. The rows are obtained by using the statement handle with maxdb_fetch(3). RETURN VALUES
maxdb_stmt_result_metadata(3) returns a result resource or FALSE if an error occurred. EXAMPLES
Example #1 Object oriented style <?php $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB"); $maxdb->query("CREATE TABLE temp.friends (id int, name varchar(20))"); $maxdb->query("INSERT INTO temp.friends VALUES (1,'Hartmut')"); $maxdb->query("INSERT INTO temp.friends VALUES (2, 'Ulf')"); $stmt = $maxdb->prepare("SELECT id, name FROM temp.friends"); $stmt->execute(); /* get resultset for metadata */ $result = $stmt->result_metadata(); /* retrieve field information from metadata result set */ $field = $result->fetch_field(); printf("Fieldname: %s ", $field->name); /* close resultset */ $result->close(); /* close connection */ $maxdb->close(); ?> Example #2 Procedural style <?php $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB"); maxdb_query($link, "CREATE TABLE temp.friends (id int, name varchar(20))"); maxdb_query($link, "INSERT INTO temp.friends VALUES (1,'Hartmut')"); maxdb_query($link, "INSERT INTO temp.friends VALUES (2, 'Ulf')"); $stmt = maxdb_prepare($link, "SELECT id, name FROM temp.friends"); maxdb_stmt_execute($stmt); /* get resultset for metadata */ $result = maxdb_stmt_result_metadata($stmt); /* retrieve field information from metadata result set */ $field = maxdb_fetch_field($result); printf("Fieldname: %s ", $field->name); /* close resultset */ maxdb_free_result($result); /* close connection */ maxdb_close($link); ?> The above example will output something similar to: Fieldname: ID SEE ALSO
maxdb_prepare(3), maxdb_free_result(3). PHP Documentation Group MAXDB_STMT_RESULT_METADATA(3)
All times are GMT -4. The time now is 09:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy