export command within shell script

Posted by shantanuo on Server Fault See other posts from Server Fault or by shantanuo
Published on 2011-11-14T06:17:57Z Indexed on 2011/11/14 9:57 UTC
Read the original article Hit count: 293

When I use export command at command prompt, it works as expected. But it does not work from shell script.

[[email protected] shantanu]# export myip=10
[[email protected] shantanu]# echo $myip
10
[[email protected] shantanu]# vi myip.sh
#!/bin/sh
export myipadd=10

[[email protected] shantanu]# sh -xv myip.sh
#!/bin/sh
export myipadd=10
+ export myipadd=10
+ myipadd=10

[[email protected] shantanu]# echo $myipadd

I want to make the variable available to the same script next time when it runs. In other words I am looking for some way to memorize the variable value.

© Server Fault or respective owner

Related posts about shell

Related posts about shell-scripting