smbclient 的退出码 [英] Exit codes of smbclient

查看:44
本文介绍了smbclient 的退出码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 arm 上 samba 的命令行命令smbclient"有问题.

i've a problem with the commandline command "smbclient" of samba on arm.

我编写了一个脚本来从 Windows 共享下载文件.这里是这个脚本的 smb 部分.

I wrote a script to download files from a Windows Share. Here the smb-part of this script.

smbclient  //CNAME/SNAME -I0.0.0.0 -N -c "case_sensitive; cd folder; prompt; mget file"
echo $?

我的问题是退出代码.如果文件下载完成,退出代码为0(OK)如果文件无法下载,退出代码为 1(OK)如果 testmaschine 由于下载文件而失去与共享的连接,则退出代码为 0(不好),但错误(丢失连接...等")会写入控制台.(好)

My problem ar the exit codes. If the file is downloaded completely, the exit code is 0 (OK) If the file cannot be downloaded, the exit code is 1 (OK) If the testmaschine loses the connection to the share due downloading a file, the exit code is 0 (NOT GOOD), but error ("Lost connection...etc.") is written to console. (OK)

我尝试了两个不同的版本.桑巴-3.0.32桑巴-3.6.19两者都一样.

I tried it with two different versions. samba-3.0.32 samba-3.6.19 Both the same.

有人知道一个好的解决方法(或 smbclient-argument)让我的脚本知道下载失败了吗?

Does someone know a good workaround (or smbclient-argument) to let my script know, that the download failed?

附注.我检查了 smbclient 来源.看起来他们忘记设置退出代码了.因为每次出现另一个错误时都会设置 Errormessage 并执行(例如 exit(1)).但是对于超时,他们只设置错误消息.

PS. I checked the smbclient sources. It looks like they forgot to set the exitcode. Because everytime there is another error the set the Errormessage and do an (e.g. exit(1)). But for timeouts, they only set the Errormessage.

先谢谢你!

推荐答案

最好是使用 -E 参数到 smbclient 并从命令行重定向 2>/errorlog.然后,您可以检查此文件以查看是否发生了任何错误.

What would be best is to use the -E argument to smbclient and redirect 2>/errorlog from the command line. You can then check this file to see if any errors occurred.

警告,第一行总是 Domain=......... 所以你可能需要去掉那一行.

Warning, the first line is always the Domain=......... so you may need to strip that line out.

像这样:

smbclient Hostname -A authfile -E 1>log 2>errorlog <<-EOF 
get foo 
EOF

在错误日志中,您应该会找到类似下面的内容,您的日志文件将为空

In the errorlog you should find something like below, your log file will be empty

域=[主机名] OS=[Windows Server 2008 R2 标准 7601 服务Pack 1] Server=[Windows Server 2008 R2 Standard 6.1]NT_STATUS_OBJECT_NAME_NOT_FOUND 打开远程文件 \foo

Domain=[Hostname] OS=[Windows Server 2008 R2 Standard 7601 Service Pack 1] Server=[Windows Server 2008 R2 Standard 6.1] NT_STATUS_OBJECT_NAME_NOT_FOUND opening remote file \foo

这篇关于smbclient 的退出码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆