Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 使用PSFTP的时间戳和更高级别的详细日志记录_Windows_Batch File_Command Line_Sftp_Psftp - Fatal编程技术网

Windows 使用PSFTP的时间戳和更高级别的详细日志记录

Windows 使用PSFTP的时间戳和更高级别的详细日志记录,windows,batch-file,command-line,sftp,psftp,Windows,Batch File,Command Line,Sftp,Psftp,我需要将详细日志添加到另一个系统的FTP中,因为他们声称并不总是接收发送的文件 我正在使用脚本调用psftp.exe,并尝试使用-v选项进行详细日志记录。我还想在日志文件或日志内部添加时间戳 我还注意到使用-v3和-v4可以显示更详细的日志记录。我希望将其输出到一个文件中 这是我的油灰电话: \\myserver\mytable\psftp.exe mylogin@myipaddress -pw mypassword -b C:\Users\pervasive\Desktop\mytable\m

我需要将详细日志添加到另一个系统的FTP中,因为他们声称并不总是接收发送的文件

我正在使用脚本调用
psftp.exe
,并尝试使用
-v
选项进行详细日志记录。我还想在日志文件或日志内部添加时间戳

我还注意到使用
-v3
-v4
可以显示更详细的日志记录。我希望将其输出到一个文件中

这是我的油灰电话:

\\myserver\mytable\psftp.exe mylogin@myipaddress -pw mypassword -b C:\Users\pervasive\Desktop\mytable\mysftpscript.sftp  -v 2> \\myserver\mytable\mylog.txt
要将
psftp
的完整详细(
-v
)输出记录到文件,请使用:

psftp user@example.com -pw password -v > psftp.log 2>&1
另见


无法使
psftp
生成时间戳



请注意,
psftp
中没有详细级别。没有
-v3
-v4
我希望我能投票支持你的答案,但我仍然没有代表权

目录>>a.txt 2>&1


这确实把他们放在一个里面了!唯一的退路是它把STDRR追加到末端,而不是把它放在中间,就像它是-V一样。这是迄今为止我找到的最好的解决方案,但仍然比我的客户希望看到的要少一点。时间戳也不错,但我在开始和结束时添加了一个时间戳来封装流程。

虽然它不会给出每个事务的时间,但可以在两组日期和时间命令之间的bat文件中使用psftp命令。这至少会框定psftp运行的开始和结束

date /t > \\myserver\mytable\mylog.txt
time /t >> \\myserver\mytable\mylog.txt
\\myserver\mytable\psftp.exe mylogin@myipaddress -pw mypassword -b C:\Users\pervasive\Desktop\mytable\mysftpscript.sftp  -v >> \\myserver\mytable\mylog.txt 2>&1
date /t >> \\myserver\mytable\mylog.txt
time /t >> \\myserver\mytable\mylog.txt
要获取每事务时间日志记录,可以使用以下命令从sftp批处理/script C:\Users\pervasive\Desktop\mytable\mysftpscript.sftp运行Windows命令!命令在关键点上记录您需要的时间

!time /t
mput somefiles
!time /t
编辑:刚刚测试了time命令,不太好。所有的时间都在输出的顶部,下面的psftp详细日志记录是没有意义的

18/12/2020 
12:07
12:07
12:07
12:07
Connected to x.x.x.x
Remote working directory is /
New local directory is C:\_sftp\snd
Remote directory is now /remote/collect
Listing directory /remote/collect

问题可能是,如果您需要第二次记录,这将不会有效,因为它只是到分钟。最后的链接有一个分秒的答案,但我还没有在sftp批处理文件中测试过!指挥部。是的,我已经离开了公司,但正如你在我去年的回复中所看到的,我能够封装前后的时间戳。您可以编写一个批处理文件来编写时间戳,然后使用日志记录的其余部分编辑该日志文件。这样的话,时间戳也就写在前面了。这对公司很有效,在过去的一年里未经编辑就被用于解决商业纠纷。为什么给我一个否定的-1?请投票给我这个答案