新手问:如何把运行时的反馈信息输出到日志

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
atealxt
帖子: 72
注册时间: 2008-11-26 16:52

新手问:如何把运行时的反馈信息输出到日志

#1

帖子 atealxt » 2009-09-25 20:04

源代码是:

代码: 全选

logger "wine uTorrent starting.."
nohup wine /media/WinXP_C/Program\ Files/uTorrent/utorrent.exe &
logger "wine uTorrent started"
中间那行应该是运行出错了,我如何接受错误信息?
试了下面这样不行:

代码: 全选

logger "wine uTorrent starting.."
msg=nohup wine /media/WinXP_C/Program\ Files/uTorrent/utorrent.exe &
#logger $msg #error happened:(
logger "wine uTorrent started"
在终端中手动运行的话,终端会打印出一些反馈信息,能把这些信息接收并输出到什么地方好能看到么?
(这点解决了)

代码: 全选

nohup wine /media/WinXP_C/Program\ Files/uTorrent/utorrent.exe >/PATH/ut_log &
[/color]

另,shell能不能实现高级语言这样或类似的功能?

代码: 全选

try{
#执行语句
}
catch{
#出错了,输出错误
}
谢谢。
上次由 atealxt 在 2009-10-02 11:58,总共编辑 1 次。
头像
darkfish
帖子: 90
注册时间: 2009-09-18 10:03
来自: 北京
联系:

Re: 新手问:如何把运行时的反馈信息输出到日志

#2

帖子 darkfish » 2009-09-25 20:32

logger到特定文件的时候不是应该加 -f 的参数么??
-----------------
输出重定向不可以么?
-----------------
试试
[[ 尝试运行 ]] && echo "success" || echo "error"
头像
atealxt
帖子: 72
注册时间: 2008-11-26 16:52

Re: 新手问:如何把运行时的反馈信息输出到日志

#3

帖子 atealxt » 2009-09-25 23:53

logger到特定文件的时候不是应该加 -f 的参数么??
-f不是去哪而是从哪来
http://unixhelp.ed.ac.uk/CGI/man-cgi?logger+1
输出重定向不可以么?
你说的是>或者>>么?
用>或者>>好像不可以,输出的文件里啥都没有。
----------------------
这点可以了,当时语法没写对
[[ 尝试运行 ]] && echo "success" || echo "error"
你指的是不是test?
回复