Run a script which will execute the commands in a file and save seperate log for each command [1]

Run a script which will execute the commands in a file and save seperate log for each command

Monday, September 17, 2018 7:21 AM - Mahesh Gaali

Hi,

I am working on the telecom server with SSH login. I need to take the log for 100s of commands and save the result of each command in separate log file.


Can you suggest how i can do this task executing the commands from a file and saving the log for each command separately using Xshell. Thank you.

Program Ver. : Xshell 6


Re: Run a script which will execute the commands in a file and save seperate log for each command

Thursday, September 27, 2018 3:17 PM - Support

You can use some APIs related to logging. Here is a sample VBscript related to logging.

Sub Main
xsh.Screen.Synchronous = true

'*** StartLog, StopLog ***
xsh.Session.LogFilePath = "your_path\a.log"
xsh.Session.StartLog()
xsh.screen.send("echo a.log"&vbcr)
xsh.screen.send("ls"&vbcr)
xsh.Session.Sleep(1000)
xsh.Session.StopLog()
xsh.Session.LogFilePath = "your_path\b.log"
xsh.Session.Sleep(1000)
xsh.Session.StartLog()
xsh.screen.send("echo b.log"&vbcr)
xsh.screen.send("ls"&vbcr)
xsh.Session.Sleep(1000)
xsh.Session.StopLog()
End Sub

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog


Previous views: 332