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

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

问题描述

我的手臂上的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(确定) 如果无法下载文件,则退出代码为1(确定) 如果testmaschine由于下载文件而失去了与共享的连接,则退出代码为0(不正确),但是错误("Lost connection ... etc.")被写入控制台. (确定)

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?

PS.我检查了smbclient的来源.看来他们忘记了设置退出代码.因为每次都有另一个错误,请设置Errormessage并执行(例如exit(1)).但是对于超时,它们仅设置Errormessage.

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

Domain = [主机名] OS = [Windows Server 2008 R2 Standard 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天全站免登陆