对于以下脚本
install.csh:
#!/bin/csh -f tar -zxf Python-3.1.1.tgz cd Python-3.1.1 ./configure make make install cd .. rm -rf Python-3.1.1
有可能的使用:
./install.csh |& tee install.log
Run Code Online (Sandbox Code Playgroud)
如何更改脚本以便我仍然在控制台上获得install.log和输出而不要求用户进行重定向?
一些简单的解决方
解决方案1:开发每条想要独立登录的线路,利用-a三通开关追加
#!/bin/csh -f
tar -zxf Python-3.1.1.tgz |& tee -a install.log
cd Python-3.1.1 |& tee -a install.log
./configure |& tee -a install.log
make |& tee -a install.log
make install |& tee -a install.log
cd .. |& tee -a install.log
rm -rf Python-3.1.1 |& tee -a install.log
Run Code Online (Sandbox Code Playgroud)
解决方案2:添加第二个脚本.例如,将当前install.csh重命名为install_commands,然后添加新的install.csh脚本:
#!/bin/csh -f
/bin/csh install_commands |& tee install.log
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17676 次 |
| 最近记录: |