Jump to content
Ketarin forum

variables not resolving on commands in c# script


Anonymous
 Share

Recommended Posts

I'm attempting to create a command that emails me upon the completion of an update (this would be a nice feature to see natively in Ketarin).

 

The problem: the email I receive shows the unresolved variable names.

 

In the execute after the download section, I have the following C# script:

 

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

message.To.Add("email_address@domain.com");

message.Subject = "{appname} has been updated to {version}";

message.From = new System.Net.Mail.MailAddress("email_address@domain.com");

message.Body = "SHA256: {sha256}";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.domain.com");

smtp.Send(message);

 

The log (collected by running as Batch script) shows:

 

5/3/2012 1:45:53 PM: LibreOffice: Replacing {version} in 'System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

message.To.Add("email_address@domain.com");

message.Subject = "LibreOffice has been updated to {version}";

message.From = new System.Net.Mail.MailAddress("email_address@domain.com");

message.Body = "SHA256: {sha256}";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.domain.com");

smtp.Send(message);' with '3.5.3'

5/3/2012 1:45:53 PM: LibreOffice: Replacing {version} in 'http://download.documentfoundation.org/libreoffice/stable/{version}/win/x86/LibO_{version}_Win_x86_install_multi.msi.sha256' with '3.5.3'

5/3/2012 1:45:54 PM: LibreOffice: Replacing {sha256} in 'System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

message.To.Add("email_address@domain.com");

message.Subject = "LibreOffice has been updated to 3.5.3";

message.From = new System.Net.Mail.MailAddress("email_address@domain.com");

message.Body = "SHA256: {sha256}";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.domain.com");

smtp.Send(message);' with '163e4de6f6eb3a2d85427d1989926b896abd688b3a069ab1552540c21c3afcf2'

5/3/2012 1:45:54 PM: LibreOffice: Executing command: System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

5/3/2012 1:45:54 PM: LibreOffice: Executing command: message.To.Add("email_address@domain.com");

5/3/2012 1:45:54 PM: LibreOffice: Executing command: message.Subject = "LibreOffice has been updated to 3.5.3";

5/3/2012 1:45:54 PM: LibreOffice: Executing command: message.From = new System.Net.Mail.MailAddress("email_address@domain.com");

5/3/2012 1:45:54 PM: LibreOffice: Executing command: message.Body = "SHA256: 163e4de6f6eb3a2d85427d1989926b896abd688b3a069ab1552540c21c3afcf2";

5/3/2012 1:45:54 PM: LibreOffice: Executing command: System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.domain.com");

5/3/2012 1:45:54 PM: LibreOffice: Executing command: smtp.Send(message);

5/3/2012 1:45:54 PM: LibreOffice: Command result: Microsoft Windows [Version 6.1.7601]

 

Are variables supposed to resolve when running a C# script, or is this just a pipe dream?

Link to comment
Share on other sites

  • 1 month later...

Oh, you are using a C# script. Nice. But it won't work that way ;)

 

You need to do it this way:

 

x = app.Variables.ReplaceAllInString("This is my {variable} string")

 

or like this:

 

x = UrlVariable.GlobalVariables.ReplaceAllInString("This is my {variable} string")

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.