Can we store a value in temp variable which can accessible?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can we store a value in temp variable which can accessible?
# 1  
Old 07-11-2012
Can we store a value in temp variable which can accessible?

Hi techies
I am trying to write a script which can give me a ATP of a job,
My idea is :
store a value in a temp variable, next script read the variable in next call of it and give me the diff of values which is ATP, as script is running every hours.

Can we do this in Shell Script.
If someone have better idea, please let me know
# 2  
Old 07-11-2012
"Yes w... you can!". No clue what a ATP is, but what have you tried so far?
If the script ends it's lifecycle, variables will be lost. Maybe write it to a temp file.
If it is a permanent running script like a daemon, you can use a variable of course.
# 3  
Old 07-11-2012
Thanks man
Can you please let me know how can I do this ? if possible, give me a example
# 4  
Old 07-30-2012
Can you please give me example
# 5  
Old 07-30-2012
Have you even framed ur script?
# 6  
Old 07-30-2012
Hi
right now, I am storing the values in a temp file and whenever the script run again , it read this file and compare the values from the first one and give me the difference of values.
I wanted to remove this temp file with temp variable. Is it possible ?

my script
Code:
vbefore=`cat temp` ## Can we replace this temp file
vafter=`db2 "select count(*) from tablename" | grep [0-9]`

diff=`expr $vafter - $vbefore

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Store ^M character in variable

Hi, I want to store ^M character in a variable to be later written to a file. Can you please help. TempOut="$_var1 `print '\x0D'` $_var1" ..... .... echo $TempOut >> logfile TempOut="$_var1 `echo -e '\x0D'` $_var1" ..... .... echo $TempOut >> logfile But both ways I am... (2 Replies)
Discussion started by: tostay2003
2 Replies

2. Shell Programming and Scripting

I can't store value in the variable

!#bin/bash clear var= grep @gmail.com email.txt | wc -l echo $var echo $var exit 0 OUTPUT: 1000 _ _ Where _ represent space (no value or nothing) (4 Replies)
Discussion started by: Muhammad Rehan
4 Replies

3. Shell Programming and Scripting

How do I store stdout in a variable?

These seems ridiculously simple but I can't get it to work. Using korn shell and I want to pass in a flag to tell my echo statements to either write to the screen for debugging or a file if not. So I have something like: if ; then logout=&1 else logout='logfile.out' fi Then... (2 Replies)
Discussion started by: DJR
2 Replies

4. Shell Programming and Scripting

Store the name of an extracted file to a temp file

What would be the best way to store the name of an extracted file from a tar to a text file? I want to extract one file from a tar and store the name of the extracted file to a temp file. tar -xvf tar_file.tar file_to_be_extracted (1 Reply)
Discussion started by: erin00
1 Replies

5. Programming

how to store string in variable

sorry i'm newbies c programer how to store string to variable with value flexible. example int hh=1; ---> value flexible 1,2,3,4,5; int xx=1; ---> value flexible 1,2,3,4,5; char test="value=%d and value=%d",hh,xx; --> not working char test2="value2=%d and value2=%d",hh,xx; --> not... (1 Reply)
Discussion started by: slackman
1 Replies

6. Shell Programming and Scripting

cut and store last value of a variable into other

Hi All, I am a newbie to unix.starting my career in unix.need 1 help from you all..pls help.. i am passing a file name "abc_delta" as argument to my script1.sh. if file name contains "_delta" at last then echo pass else fail.how to fix it. Note:file name will always contain "_delta" at... (10 Replies)
Discussion started by: pradeepcarya
10 Replies

7. UNIX for Advanced & Expert Users

Setting a permanent global variable in unix accessible from any script

Is there anyway in which i can set a permanent global variable in unix, which when initialised with a value and modified during any shell script, would retain its value even if i logout and login I dont know whether i am being able to express my need clearly but basically what i want is a... (3 Replies)
Discussion started by: arindamlive
3 Replies

8. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

9. Shell Programming and Scripting

Store o/p of awk in a variable

Hi , Here is my script echo 'Enter MSISDN for the Calling Number' read ms acc=`sqlplus -s testing/testing123@BP_$ARBORENV<<EOF set heading off; set feedback off; select external_id from external_id_equip_map where subscr_no = (select subscr_no from external_id_equip_map where account_no =... (1 Reply)
Discussion started by: Pratik4891
1 Replies

10. Shell Programming and Scripting

To store the output in a variable

Hi, I am getting the following error while executing the script. Please can someone throw some light where is the problem. Many thanks. ./check: temp: not found The directory related to SEP instance 4 does not exist. The script is as follows. SEP_APP="/scp/sepx/app... (2 Replies)
Discussion started by: Sudhakar333
2 Replies
Login or Register to Ask a Question