Howdy - These forums are great, and I'm hoping to get some help with a headache I have on doing a process manually that should be easier to automate than I've found it to be.
I have a command line tool from a vendors app that will upload logs for the app. The tool only takes Unix UTC time though, and I need to run the scheduled task 3 to 4 times a day to upload the app logs. I could probably just upload all the logs for the day, but that's still a problem as I can't figure out how to do that in a script. So I could just upload all the logs for the entire day and not worry about only uploading the latest logs.
The command is in the powershell script I started which is below, but if it's easier to do this with a batch file i could, I was just trying to avoid adding something like blat to send the email and also I couldn't figure out how to get the task result in a batch script which is what I need to send in the email.
The "IEX" below is the full command, and that's where I need to populate the UTC time for the day if that's easier than trying to get the time from the last time the scheduled task ran, it's the safest option anyway. Then the "1 1" at the end are parameters the vendor requires which add options for the upload.
How can I populate the current day and time for the log upload? If it's the time such as 12:01am (eastern) to 11:59pm (eastern) that is populated each day that should be fine?
# "iex" is an alias for the invoke-expression cmd
**iex c:\path_to_exe\myprog.exe -a 1379300570 1379300570 1 1**
# $? lets us know if the previous command was successful or not
# $LASTEXITCODE gives us the exit code of the last Win32 exe execution
if (!$? -OR $LASTEXITCODE -gt 0)
{
$smtpServer = "smtp.mydomain.com"
$fromAddress = "sender@mydomain.com"
$toAddress = "recipient@mydomain.com"
$subject = "FAILURE"
$msgBody = "Trouble with Task"
# Use these variables if auth for the SMTP server is required!
$senderCreds = new-object System.Net.networkCredential
$senderCreds.UserName = "senderusername"
$senderCreds.Password = "senderpwd"
$smtpClient = new-object Net.Mail.SmtpClient($smtpServer)
$smtpClient.Credentials = $senderCreds
$smtpClient.Send($fromAddress,$toAddress,$subject,$msgBody)
}
I have a command line tool from a vendors app that will upload logs for the app. The tool only takes Unix UTC time though, and I need to run the scheduled task 3 to 4 times a day to upload the app logs. I could probably just upload all the logs for the day, but that's still a problem as I can't figure out how to do that in a script. So I could just upload all the logs for the entire day and not worry about only uploading the latest logs.
The command is in the powershell script I started which is below, but if it's easier to do this with a batch file i could, I was just trying to avoid adding something like blat to send the email and also I couldn't figure out how to get the task result in a batch script which is what I need to send in the email.
The "IEX" below is the full command, and that's where I need to populate the UTC time for the day if that's easier than trying to get the time from the last time the scheduled task ran, it's the safest option anyway. Then the "1 1" at the end are parameters the vendor requires which add options for the upload.
How can I populate the current day and time for the log upload? If it's the time such as 12:01am (eastern) to 11:59pm (eastern) that is populated each day that should be fine?
# "iex" is an alias for the invoke-expression cmd
**iex c:\path_to_exe\myprog.exe -a 1379300570 1379300570 1 1**
# $? lets us know if the previous command was successful or not
# $LASTEXITCODE gives us the exit code of the last Win32 exe execution
if (!$? -OR $LASTEXITCODE -gt 0)
{
$smtpServer = "smtp.mydomain.com"
$fromAddress = "sender@mydomain.com"
$toAddress = "recipient@mydomain.com"
$subject = "FAILURE"
$msgBody = "Trouble with Task"
# Use these variables if auth for the SMTP server is required!
$senderCreds = new-object System.Net.networkCredential
$senderCreds.UserName = "senderusername"
$senderCreds.Password = "senderpwd"
$smtpClient = new-object Net.Mail.SmtpClient($smtpServer)
$smtpClient.Credentials = $senderCreds
$smtpClient.Send($fromAddress,$toAddress,$subject,$msgBody)
}