【发布时间】:2020-12-05 11:09:58
【问题描述】:
这很简单。我正在尝试在第二个脚本中设置我的变量。我尝试了多种方法但不起作用。因此,所有注释掉的部分。您运行的第一个脚本 IE:unit3.2a.sh 3 5 这将返回 8。第二个脚本应将结果读取为 8。我正在使用 cygwin。
unit3.2a.sh '''
#!/bin/csh
set a = 0
set b = 0
set c = 0
@ a = $1
@ b = $2
@ c = $a + $b
echo $c
'''
unit3.sh '''
#!/bin/csh
a=$(~./unit3.2a.sh)
#below is all that don't work!
#instructors: a =~./unit3.2a.sh 2 200
#./unit3.2a.sh "2" "200"
#~./unit3.2a.sh 2 200
#=$(./unit3.2a.sh 2 200)
#=$(./unit3.2a.sh)+(2 200)
#$(./unit3.2a.sh 2 200)
#$(/home/Admin/unit3.2a.sh)
#$(/home/Admin/unit3.2a.sh 2 200)
#added echo $a to see if I wasnt seeing anything the echo text works fine but a variable does not read?
#set a='./unit3.2a.sh 2 200'
##set a=$(cat ./unit3.2a.sh 2 200)
#$ ./unit3.sh
#cat: 2: No such file or directory
#cat: 200: No such file or directory
#set a=$(~./unit3.2a.sh 2 200)
#a=$(~./unit3.2a.sh 2 200)
echo $a
echo "The result is: $a"
echo "Storing the results.............."
echo "Storing the result: $a" >> unit3.txt
echo "The script is over"
'''
【问题讨论】:
-
我不清楚您的用例在这里,但您知道
csh的setenv与set及其区别吗?setenv就像其他 shell 中的export。它使变量对父csh的子进程可见。祝你好运。
标签: linux bash cygwin csh tcsh