问题描述
这很简单。我试图在第二个脚本中设置变量。我尝试了多种方法,但没有用。因此,所有注释掉的部分。运行IE:unit3.2a.sh 3的第一个脚本3将返回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"
'''
解决方法
请注意:
example_list = [
['a','b','c'],['f','g','h'],['i','j','k'],]
my_string = ''
for s in example_list:
if example_list[-1] == s:
my_string += str(tuple(s))+';'
else:
my_string += str(tuple(s))+',\n'
print(my_string)
指的是特定的文件位置
~./unit3.2a.sh
引用当前目录中的文件
./unit3.2a.sh
格式是bash特定的,在C shell中不起作用,请参见
https://www.grymoire.com/Unix/Csh.html#uh-21
$( command )
产生以下内容的
#!/bin/csh
set a = `./unit3.2a.sh 2 2`
echo $a
echo "The result is: $a"
echo "Storing the results.............."
echo "Storing the result: $a" >> unit3.txt
echo "The script is over"