最近下载的代码是#!/bin/csh,但是由于我用的是ubuntu,所以改成#!/bin/bash,但是仍然不能运行,我发现可以再csh shell中使用的定义语句,如set outfile = flow.STEHE.ps在bash中不能使用
请问如何转换脚本,使再bash下面也可以很方便的运行?谢谢
bash和csh的shell脚本的差别???(已解决)
-
- 帖子: 39
- 注册时间: 2011-03-28 19:14
bash和csh的shell脚本的差别???(已解决)
上次由 wslgyd 在 2012-01-19 21:07,总共编辑 1 次。
- 枫叶饭团
- 帖子: 14683
- 注册时间: 2010-06-16 1:05
- 系统: Mac OS X
- 来自: Tencent
- 联系:
Re: bash和csh的shell脚本的差别???
裝csh吧,移植明顯要蛋疼些
-
- 帖子: 39
- 注册时间: 2011-03-28 19:14
Re: bash和csh的shell脚本的差别???
也只能这么着了,不知到换了csh以后对以前安装的软件有没有影响枫叶饭团 写了:裝csh吧,移植明顯要蛋疼些
安装sch是不是
代码: 全选
sudo apt-get install csh
-
- 帖子: 39
- 注册时间: 2011-03-28 19:14
Re: bash和csh的shell脚本的差别???
我安装了csh,然后换乘%,代码如下,结果是command not found,很奇怪,因为我把定义的变量去掉的那个bash文件却是可以运行的,请问各位高手怎么回事啊?谢谢
代码: 全选
#!/bin/csh
## Plot monthly discharge, using the Stehekin basin as an example
gmtset ANOT_FONT_SIZE 14 LABEL_FONT_SIZE 14 HEADER_FONT_SIZE 16
set outfile = flow.STEHE.ps
set projPage = -Jx1
set coordPage = -R0/8.5/0/11
set projData = -JX5T/1.5
set coordData = -R1950-01-01T00:00:00/1951-12-31T00:00:00/0/7000
set pen_obs = "-W5,black"
set pen_sim = "-W5,blue,--"
set projText = -JX5/1.5
set coordText = -R0/1/0/1
gmtset D_FORMAT "%lg"
gmtset INPUT_DATE_FORMAT "yyyy-mm"
gmtset OUTPUT_DATE_FORMAT "yyyy-mm"
gmtset PLOT_DATE_FORMAT "yyyy-mm"
gmtset TIME_IS_INTERVAL +1o
set obsfile = ../obs/flow.STEHE.month.cfs
set simfile = ../results/rout/STEHE.month
## Set up page
pstext -P -K -V -N $projPage $coordPage -Y11 -X1 <<END> $outfile
END
## plot data ---------------------------------------
perl -e 'while (<>) {chomp; s/^\s+//; @fields = split /\s+/; printf "%04d-%02d %.4f\n", $fields[0],$fields[1],$fields[2];}' $obsfile |\
psxy -O -K -V $projData $coordData -Y-2 -X0 $pen_obs --FRAME_PEN=1.5p --TICK_PEN=1p --TICK_LENGTH=-0.2c -Ba1yf1o:"Time":/1000:"Flow (cms)"::.:SWne >> $outfile
perl -e 'while (<>) {chomp; s/^\s+//; @fields = split /\s+/; printf "%04d-%02d %.4f\n", $fields[0],$fields[1],$fields[2];}' $simfile |\
psxy -O -K -V $projData $coordData $pen_sim >> $outfile
pstext -O -K -V -N $projText $coordText <<END>> $outfile
0.15 0.8 10 0 0 5 Observed
END
pstext -O -K -V -N $projText $coordText <<END>> $outfile
0.15 0.7 10 0 0 5 Simulated
END
psxy -O -K -V $projText $coordText $pen_obs <<END>> $outfile
0.025 0.8
0.125 0.8
END
psxy -O -K -V $projText $coordText $pen_sim <<END>> $outfile
0.025 0.7
0.125 0.7
END
## Finish the plot
pstext -O -V -N $projText $coordText <<END>> $outfile
END
-
- 帖子: 39
- 注册时间: 2011-03-28 19:14
Re: bash和csh的shell脚本的差别???
搞定了,居然是最弱智的错误,忘记chmod u+x plot_flow_STEHE.scr
-
- 帖子: 6548
- 注册时间: 2008-10-31 22:12
- 系统: 践兔
- 联系:
-
- 帖子: 39
- 注册时间: 2011-03-28 19:14
Re: bash和csh的shell脚本的差别???(已解决)
其实我也不懂,刚开始tusooa 写了:都用perl了,为啥还要在shell里调用。。。