Chinaunix

标题: 用shell写交互命令(形容不太好具体看帖子内容) [打印本页]

作者: luobingyin    时间: 2014-07-14 13:30
标题: 用shell写交互命令(形容不太好具体看帖子内容)
目前在使用Linux做电路仿真,在使用的时候我一般会将多个命令写在一个文件里,然后source这个文件(我将它命名为RunSimulation),就可以运行仿真,文件内容大致如下:
RunSimulation
"
rm *.tr*
rm *.lis*
...
rm *.mt*
#删除之前仿真生成的文件
hspice -mt 8 -i testbench.sp -o testbench.lis&
"

hspice是一个仿真器的命令
现在需要使用多个仿真器进行仿真,因此命令的文本就变成了:
RunSimulation
"
rm *.tr*
rm *.lis*
...
rm *.mt*
#删除之前仿真生成的文件
hspice -mt 8 -i testbench.sp -o testbench.lis&
aps +mt=4 -i testbench.scs &
adit -spice -i testbench.sp&
...
"

每次仿真使用仿真器的时候,我都必须使用#将其他不想用的注释掉,由于仿真软件太多,注释起来太麻烦,想将这个命令文件进行一下改造,在source RunSimulation并且各种rm运行完成后能不能停下来询问使用那种仿真命令,比如
1对应hspice -mt 8 -i testbench.sp -o testbench.lis&
2对应aps +mt=4 -i testbench.scs &
3对应adit -spice -i testbench.sp&
如果我想用hspice仿真就在terminal里面输入1然后回车,程序就能以hspice进行仿真。

这样每次使用时就不用频繁注释这个命令文件RunSimulation了,小弟linux不太懂(基本是0基础),请求各位大神帮助,只要提供一个思路即可,谢谢啦~~~

如果有什么没有解释清楚的,我再仔细解释。
PS:应该是可以通过shell'语言来解决吧,感觉应该跟windows里面bat文件差不多,不过那个我也不太明白:wink:

作者: luobingyin    时间: 2014-07-14 13:36
还有一个问题呀,我把RunSimulation这个文件放在~/script下面了,之后在.cshrc里面添加了~/script这个路径,为什么我在terminal里面输入source RunSimulation系统会提示说 No such file or directory呢?

我在echo $path里面已经看到了我添加的~/script这个路径了呀


作者: ly5066113    时间: 2014-07-14 13:36
回复 1# luobingyin


用 case 就可以了,看看刚出炉的总结:
http://bbs.chinaunix.net/thread-4145766-1-1.html
作者: 关阴月飞    时间: 2014-07-14 13:37
本帖最后由 关阴月飞 于 2014-07-14 13:37 编辑

回复 1# luobingyin

比如
1对应hspice -mt 8 -i testbench.sp -o testbench.lis&
2对应aps +mt=4 -i testbench.scs &
3对应adit -spice -i testbench.sp&

目测是这个意思:
  1. rm *.tr*
  2. rm *.lis*
  3. ...
  4. rm *.mt*
  5. read -p "pls input num: " num
  6. case "$num" in
  7.     1) hspice -mt 8 -i testbench.sp -o testbench.lis& ;;
  8.     2) aps +mt=4 -i testbench.scs & ;;
  9.     3) adit -spice -i testbench.sp& ;;
  10. esac
复制代码

作者: q1208c    时间: 2014-07-14 13:55
回复 4# 关阴月飞


      如果我输入了6会怎样?
作者: luobingyin    时间: 2014-07-14 13:59
回复 4# 关阴月飞

试了一下 没有read这个命令啊:

read: Undefine variable

......


   
作者: luobingyin    时间: 2014-07-14 14:17
回复 4# 关阴月飞


    刚才弄了下用bshell可以写,但是如果想用cshell该怎么弄呢?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2