您的位置:首页 > 运维架构 > Linux

windows 系统直接访问linux系统 的便捷方法

2014-12-30 15:16 579 查看
有很多博客介绍了: 如下
http://www.cnblogs.com/echo-something/archive/2012/09/20/pscp.html http://blog.csdn.net/zyz511919766/article/details/27546515
1. 用到一个公开的工具包 putty

2. 可以写一个 bat程序做一些批量操作和自动化操作

使用例子如下

cd D:\tools\putty
D:
pscp -pw 888888 root@192.1.51.195:/root/script/time_solidify.sh ./
updateDate.vbs
pscp -l root -pw 888888 ./time_solidify.sh 192.1.51.195:/root/script/time_solidify.sh


'  读指定的文件
Dim  pathway
Dim fso,myfile,newfile,i,flag,currentdate
pathway = "D:\tools\putty\time_solidify.sh"
new_pathway = "D:\tools\putty\new_time_solidify.sh"
flag = 1
Set fso = CreateObject ("Scripting.FileSystemObject")
If fso.FileExists (pathway) Then
Set myfile = fso.OpenTextFile (pathway,1,false)
If fso.FileExists (new_pathway) Then
' 清空
fso.DeleteFile (new_pathway)
end if
Set newfile = fso.CreateTextFile (new_pathway,false)
else
flag = 0
End If
Set regEx = New RegExp
regEx.Pattern = ".*\d{4}-\d{2}-\d{2}.*"
If flag=1 Then
do
txt = myfile.ReadLine()
If regEx.Test(txt) Then
' 取得日期
vartxt = txt
currentdate = mid(txt,instr(txt,chr(34))+1,10)
currentdate = DateAdd("d",1,currentdate)
currentdate = format_time(currentdate,2)
temptxt = "date -s "&chr(34)¤tdate&" "&chr(34)&"${now_time}"
' 修改后的日期进行添加新的文件当中
newfile.WriteLine(temptxt)
else
'  添加内容
newfile.WriteLine(txt)
End If
loop while (not myfile.AtEndOfStream)
End If
'  旧的文件删掉
'fso.DeleteFile(pathway)
'  新的文件更名
fso.CopyFile new_pathway,pathway
'fso.DeleteFile(new_pathway)
Set myfile = nothing
Set newfile = nothing
Set fso = nothing
Set regEx = nothing
'currentdate = DateAdd("d",1,"2014-10-31")
'msgbox currentdate

Function Format_Time(s_Time, n_Flag)
Dim y, m, d, h, mi, s
Format_Time = ""
If IsDate(s_Time) = False Then Exit Function
y = cstr(year(s_Time))
m = cstr(month(s_Time))
If len(m) = 1 Then m = "0" & m
d = cstr(day(s_Time))
If len(d) = 1 Then d = "0" & d
h = cstr(hour(s_Time))
If len(h) = 1 Then h = "0" & h
mi = cstr(minute(s_Time))
If len(mi) = 1 Then mi = "0" & mi
s = cstr(second(s_Time))
If len(s) = 1 Then s = "0" & s
Select Case n_Flag
Case 1
' yyyy-mm-dd hh:mm:ss
Format_Time = y  & m & d
Case 2
' yyyy-mm-dd
Format_Time = y & "-" & m & "-" & d
Case 3
' hh:mm:ss
Format_Time = h & ":" & mi & ":" & s
Case 4
' yyyy年mm月dd日
Format_Time = y & "年" & m & "月" & d & "日"
Case 5
' yyyymmdd
Format_Time = y & m & d
End Select
End Function
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: