ChinaUnix.net
相关文章推荐:

shell export

本帖最后由 whpu000625 于 2011-04-22 13:58 编辑 我有如下三个文件 # cat test.sh[code]#!/bin/bash #!/bin/bash AA="" export AA ./test2.sh echo "======test======="AA=$AA [/code]#cat test1.sh[code]#!/bin/bash test() { AA="aaaa" } [/code]#cat test2.sh[code]#!/bin/sh . ./test1.sh test echo "=======test2======" AA=$AA [/code]test.sh中定义export出环境变量AA。 test1.sh中定义函数test用于改变AA的值,...

by whpu000625 - Shell - 2011-04-23 18:04:12 阅读(9289) 回复(12)

相关讨论

登录到系统后,系统将启动一个用户shell。在这个shell中,可以使用shell命令或声明变量,也可以创建并运行shell脚本程序。运行shell脚本程序时,系统将创建一个子shell。此时,系统中将有两个shell,一个是登录时系统启动的shell,另一个是系统为运行脚本程序创建的shell。当一个脚本程序运行完毕,它的脚本shell将终止,可以返回到执行该脚本之前的shell。从这种意义上来说,用户可以有许多shell,每个shell都是由某个shell(...

by atyu30 - BSD文档中心 - 2007-07-15 03:09:42 阅读(1162) 回复(0)

[root@JHX-LINUX-SERVER study]# cat prog1 e1=100 export e1 e2=200 e3=300 prog2 [root@JHX-LINUX-SERVER study]# cat prog2 echo $e1 $e2 $e3 $e4 [root@JHX-LINUX-SERVER study]# echo $e2 20 [root@JHX-LINUX-SERVER study]# prog1 100 200 300 e1是export到子shell里面的,e3也是,但是e2怎么到子shell里面的?无法理解

export

by o06v90o - Shell - 2016-05-19 12:06:42 阅读(1242) 回复(5)

环境:ubuntu 10.04 bash 当我在控制台使用export -f 声明全局函数时是可以的,如下:[code]#ftest() { echo "Hello $LOGNAME";} #export -f ftest #bash #ftest Hello root[/code]当我试图在脚本里面使用export -f 时就会出错,如下test.sh:[code]#!/bin/sh ftest() { echo "Hello $LOGNAME" } export -f ftest ./test2.sh[/code]如下test2.sh:[code]#!/bin/sh ftest[/code]当我运行:./test.sh 的时候报错: export: ...

by ggmove - Shell - 2012-09-25 16:59:51 阅读(3986) 回复(4)

脚本如下: #!/bin/sh export TEST=aaaa 怎么运行此脚本的时候,环境变量TEST还是不行啊? 怎么在脚本中运行已有的命令?貌似嵌入板上没的/bin/里面没有export,但是可以在板上运行export? 怎么回事??

by gigabyte - Shell - 2007-12-28 15:00:36 阅读(9887) 回复(11)

在调用SHELL过程时, 调用者其实是先运行一个子sh环境, 该子环境的输入是被调用的SHELL文件. 由于UNIX进程的独 立性, 在该子sh环境建立时, 它复制了父sh进程的环境变量. 而当它退出时, 它只是简单地终止它自身. 因为父子sh不共 用相同的环境, 所以sh提供了一个export命令, 用于把子sh 的环境变量值传送给父sh相应的环境变量. 例: $ cat >; shella #!/bin/sh aa = "abc" ^D $ cat >; shellb aa = "123" shella echo $aa ^D 运行she...

by sdccf - 其他UNIX - 2003-12-10 16:57:23 阅读(6528) 回复(2)

写了一个脚本,脚本里主要是需要执行做大量export命令, 但是后来发现运行了脚本,在console里export这些变量还是没有用,怎样使脚本里export的变量在console里生效呢? 谢谢

by totopper - Shell - 2012-02-17 14:21:25 阅读(1116) 回复(2)

#!/bin/bash procfile=/home/hbscript/proc.txt if [ ! -d /home/hbscript ]; then mkdir /home/hbscript fi ps -ef|grep jboss|grep -v grep>$procfile for mm in `awk '{print $2}' $procfile` do kill -9 "$mm">>/dev/null done ps -ef|grep jboss|grep -v grep>>/root/qqq.txt i=`sed -n "1"p /root/qqq.txt|awk '{print $1}'` if [ -z "$i" ]; then /usr/java/jboss4/bin/jboss start d=`ps -ef|grep jboss|gre...

by xxq78081502 - Shell - 2008-04-25 16:27:17 阅读(1775) 回复(3)

如题 需求, 在某个时候需要大量export,并且需要在当前终端就生效,这个怎么弄呢?谢谢

by totopper - Linux系统管理 - 2012-11-06 14:39:55 阅读(4515) 回复(10)

本帖最后由 黑色阳光_cu 于 2010-10-21 09:05 编辑 [code]DAEMON_NAME="GND" BIN_PATH="/opt/gnd" DAEMON="gnd_daemon_linux" ARGV="" LOCK_FILE="/var/lock/$DAEMON.pid" LOG_FILE="/var/log/$DAEMON.log" errno=0 pid="" start () { getpid if proc_status $pid then errno=1 echo "$DAEMON_NAME already running ..." else echo -n "Starting $DAEMON_NAME ... " ( ...

by 黑色阳光_cu - Shell - 2010-10-21 17:04:54 阅读(3482) 回复(9)

有什么办法可以得到子shell里面的设定值?比如下面的想在父shell 中得到min值 好像用export不可以 function func { min=1 max=100 while [ $min -le $max ] do echo $min min=`expr $min + 1` done } 有什么方法可以呢 网上说:“不可以将其变量从子进程到处父进程,然而通过重定向就可以做到这一点 ” ------可是怎么做呢 能不能据个例子

by xin2v - Shell - 2009-03-16 17:18:45 阅读(1581) 回复(6)