Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Plink Fun

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,52561
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Plink Fun
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Plink Fun - 10/9/2007 5:44:43 AM   
  mcds99


Posts: 416
Score: 4
Joined: 2/28/2006
Status: offline
I need (as part of my job) to keep an eye on a couple of directories on  a UNIX machine, sure I could use Putty open up sessions to each machine and go to the folder and use the ls command until the cows come home. Not something I like doing when I can make it 1 click and reduce memory use on the server. This could be changed to do the same for windows servers as well.

If you need to do this sort of monitoring this little tool might help, it uses plink (part of the putty tool set) to connect using SSH, login, run the command, and exit.

[code]
<HTML>
<head><title>Sys Mon</Title>
<HTA:Application
    Border= "thin"
    WINDOWSTATE="maximize"
    Application="SysMon"
    Scoll="No"
    Singleinstance="Yes"
    ShowInTaskbar="Yes"
    Caption="Yes">
</Head>
<Script Language="VBSCRIPT" Type = "text/vbscript">
Sub Window_Onload
  Window.resizeTo 890,830
End Sub
DIM ctr1, ctr2
ctr1 = 0
ctr2 = 0
FUNCTION srvMDP1(uName, pWord)
   ctr1 = ctr1 + 1
   Set objShell1 = CreateObject("WScript.Shell")
                                                                                                                     '### change SERVER and the /dir/dir2 to what you use.
   Set objWshScriptExec1 = objShell1.Exec("C:\Program Files\Putty\plink -ssh SERVER -l " & uName.value & " -pw " & pWord.value & " ls -lrt /dir/dir2")
   Set objStdOut1 = objWshScriptExec1.StdOut
   strOutput1 = objStdOut1.ReadAll
   DispDirmd1.value = strOutput1 & "Count: " & ctr1
END FUNCTION
FUNCTION srvMDP2(uName, pWord)
   ctr2 = ctr2 + 1
   Set objShell2 = CreateObject("WScript.Shell")
                                                                                                                        '### change SERVER and the /dir/dir2 to what you use.
   Set objWshScriptExec2 = objShell2.Exec("C:\Program Files\Putty\plink -ssh SERVER -l " & uName.value & " -pw " & pWord.value & " ls -lrt /dir/dir2")
   Set objStdOut2 = objWshScriptExec2.StdOut
   strOutput2 = objStdOut2.ReadAll
   DispDirmd2.value = strOutput2 & "Count: " & ctr2
END FUNCTION
</Script>
<body>
<Table>
<TR><td>Enter Your Username: </td><td><input type="text" name="uName"></td><td>Enter Your Password: </td><td><input type="PASSWORD" name="pWord"></td><TR>
</Table>
<Table border="1">
<TR><td><input type="BUTTON" value="SERVER1" onclick="srvMDP1 uName, pWord"><br><textarea name="DispDirmd1" rows="20" cols=100></textarea></td></tr>
<TR><td><input type="BUTTON" value="SERVER2" onclick="srvMDP2 uName, pWord"><br><textarea name="DispDirmd2" rows="20" cols=100></textarea></td></tr>
</Table>
</body>
</html>
[code]

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Plink Fun Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts