It is currently Mon, 04 Mar 2024 02:24:22 GMT



 
Author Message
 working with global (env) variables
Hello,
I seem to be having trouble passing variables between scripts.  I am
using afio to backup a 16 GB hard drive to another hard drive, and afio
has an option (-H) to run a sript when the maximum volume filesize has
been reached (which I specify with another option (-s) as 1 GB).
Anyhow, here is what I am doing:

   NO=1;
   export NO;
   PROMPT="root/backups/scripts/promptscript"
   find * -print | afio -Z -o -v -s 1000m -H $PROMPT /backup/$NO.agz;
   echo "$NO";

Where $PROMPT points to this shell script:

   NO=`expr $NO + 1`;
   echo "$NO";
   export NO;

When the $PROMPT script is called, I see that the $NO variable is
incremented, but when the top script outputs $NO (after afio finishes),
$NO still equals 1.

I understand that my use of afio may be incorrect, but I cannot confirm
that until I can get the top script to tell me that $NO equals some
value greater than 1.

What am I doing wrong?

Thanks for the help!
Ken



 Sat, 27 Sep 2003 01:14:47 GMT   
 working with global (env) variables

You cannot pass changes to variables back to the calling parent process.  This
is because when a child process is created, it takes a copy of the
environment from the parent - and cannot modify it.

I suggest you change your promptscript to write to a file instead, that your
first script can then interrogate later.

Hope this helps,
Mark.

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email ab...@newsone.net



 Sat, 27 Sep 2003 20:45:25 GMT   
 working with global (env) variables
        >
        >You cannot pass changes to variables back to the calling parent process.  This
        >is because when a child process is created, it takes a copy of the
        >environment from the parent - and cannot modify it.
        >
        >I suggest you change your promptscript to write to a file instead, that your
        >first script can then interrogate later.
        >
        >Hope this helps,
        >Mark.
        >
        >In article <3AD1EE07.12E5C...@ekkinc.com>, ekk  <e...@ekkinc.com> writes:
        >>Hello,
        >>I seem to be having trouble passing variables between scripts.  I am
        >>using afio to backup a 16 GB hard drive to another hard drive, and afio
        >>has an option (-H) to run a sript when the maximum volume filesize has
        >>been reached (which I specify with another option (-s) as 1 GB).
        >>Anyhow, here is what I am doing:
        >>
        >>   NO=1;
        >>   export NO;
        >>   PROMPT="root/backups/scripts/promptscript"
        >>   find * -print | afio -Z -o -v -s 1000m -H $PROMPT /backup/$NO.agz;
        >>   echo "$NO";
        >>
        >>Where $PROMPT points to this shell script:
        >>
        >>   NO=`expr $NO + 1`;
        >>   echo "$NO";
        >>   export NO;
        >>
        >>When the $PROMPT script is called, I see that the $NO variable is
        >>incremented, but when the top script outputs $NO (after afio finishes),
        >>$NO still equals 1.
        >>
        >>I understand that my use of afio may be incorrect, but I cannot confirm
        >>that until I can get the top script to tell me that $NO equals some
        >>value greater than 1.
        >>
        >>What am I doing wrong?
        >>
        >>Thanks for the help!
        >>Ken
        >>
        >
        >
        > -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
        >  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
        >   NewsOne.Net prohibits users from posting spam.  If this or other posts
        >made through NewsOne.Net violate posting guidelines, email ab...@newsone.net

Heres a trick that might help IN THIS CASE!!!!

NO=1;
export NO;
PROMPT="root/backups/scripts/promptscript"
NO=`find * -print | afio -Z -o -v -s 1000m -H $PROMPT /backup/$NO.agz  | tail -1`

--
---------------------------------------------------------------
 Will Renkel
 Wheaton, Ill.
 ren...@xnet.com
 luck...@xnet.com

"Golf and bowling are not a matter of life and death ...
     they transcend such trivial matters!"

"da little BIG DOG!"
---------------------------------------------------------------



 Mon, 29 Sep 2003 01:23:28 GMT   
 
   [ 3 post ] 

Similar Threads

1. global env. variables for tcsh

2. Best way to set env variables for multiple users or global

3. file contents into variable, or global variable from shell script

4. ENV Shell Variable to Normal Variable Qn

5. How to set global env in .exrc ?

6. Global definitions in ${ENV} scripts

7. EXPORTING global variables...

8. accessing a global variable

9. initialize the global variables in .so files


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software