|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Changing variable value in trap
Hi,
I was trying to change a value of a variable in trap like this trap 'display_prev_menu; start=1' 1 2 3 6 15 20 But itseems like the value doesn't actually get set to 1. It stays as what ever it was before. Can anyone help me with this pls. Thanx |
|
#2
|
|||
|
|||
|
I am able to get it.
Code:
#!/bin/sh
# FILE NAME : tmpr.sh
display_prev_menu()
{
start=12
echo display_prev_menu : $start
}
start=100
echo "start initial value: " $start
trap 'display_prev_menu;start=1;echo Trap start value : $start' 1 2 3 6 15 20
kill `ps -ex | grep tmpr.sh | grep -v grep | awk '{print $1}'`
My guess is that the start variable might have been changed at some other location in your script. To check whether it has been set / not, try echo within the trap itself. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Changing variable value in trap |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|