WinSCP exit codes - exit-code

I am scripting WinSCP into a VB.NET project and wondering is there a list of exit codes
and descriptions I can use for error handling? Checked their site but couldn't find anything.

0 = success, 1 = error.
Refer here:
https://winscp.net/eng/docs/scripting#result
https://winscp.net/eng/docs/faq_script_result

Related

Monitoring scripts and sending email when it crashes

I have some perl scripts which are scheduled using task scheduler in windows 2003 R2 and 2008. These scripts are called directly using perl.exe or via a batch file.
Sometimes these scripts fails to execute (crashes maybe) and we are not aware of these crashes.
Are there any ways a mail can be sent when these script crashes? more or less like monitoring of these scripts
Thanks in advance
Karthik
Why monitor the scripts from the outside when you can make the plugins to monitor theirself? First you can use eval in order to catch errors, and if an error occours you can send an email with the Net::SMTP module as rpg suggested. However I highly recommend you to use some kind of log file in order to keep trace of what happened right before the error and what caused the error. Your main goal should be to avoid the error. That ofcourse requires you to modify the scripts, if, for any reason, you cannot do that then the situation may be a little more complicated because you need another script.
With the Win32::Process::Info module you can retrieve running processes on Windows and check if your plugin is running or not.
while(1) {
my $found = false;
my $p = Win32::Process::Info->new;
foreach my $proc ($pi->GetProcInfo) {
if ($proc->{Name} =~ /yourscriptname/i ) {
found = true;
}
}
if ($found eq 'false') {
# send email
my $smtp = Net::SMTP->new("yoursmtpserver");
eval {
$smtp->mail("sender#test.it");
$smtp->recipient("recipient#test.it");
$smtp->data;
$smtp->datasend("From: sender#test.it");
$smtp->datasend("\n");
$smtp->datasend("To: recipient#test.it");
$smtp->datasend("\n");
$smtp->datasend("Subject: Plugin crashed!");
$smtp->datasend("\n");
$smtp->datasend("Plugin crashed!");
$smtp->dataend;
$smtp->quit;
};
}
sleep(300);
}
I did not test this code because I don't have Perl installed on Windows but the logic should be ok.
For monitoring - Please check the error code. This will help you for its failure.
For mail sending - You can use Net::SMTP module to send email. Let me know if you need a code snippet for it.
You can use PushMon to monitor your scripts. What you do is create PushMon URLs that matches the schedule of your Perl scripts. Then you should "ping" these URLs when your scripts run successfully. If these URLs are not accessed, maybe because your scripts crashed or there's a power failure, PushMon will notify you by email.
Disclaimer: I am associated with PushMon.

Can I fully customise an Xcode 4 Run Script Build Phase error/warning within the Issues Navigator and Build Logs?

I read on a blog somewhere that you can integrate your own build scripts with Xcode's Issues Navigator and Build Logs GUIs by printing messages to STDOUT using the following format:
FILENAME:LINE_NUMBER: WARNING_OR_ERROR: MSG
(Where WARNING_OR_ERROR is either warning or error)
e.g.
/path/to/proj/folder/somefile.ext:10: warning: There was a problem processing the file
Will show a Warning at line 10 of somefile.ext which reads "There was a problem processing the file". This does actually work (which is fantastic).
Is there any official documentation of this feature (I couldn't find any)?
In the Issues Navigator, I get a warning for the file somefile.ext, but the issue's title is "Shell Script Invocation Error" (my message appears underneath the title). Is there some way to set that heading, or am I stuck with that generic (and ugly) "Shell Script Invocation Error"?
It doesn't really answer your question as to whether you can customise the "Shell Script Invocation Error", but perl code doesn't get the nice error messages you describe, however if you include this perl module (or just the code from it) in your perl script, it does generate the nice error messages you talk about (still the same "Shell Script Invocation Error" title you mention). Just thought I'd share it for anyone using a perl script in Xcode and getting really lousy errors.
package XcodeErrors;
use strict;
use warnings;
$SIG{__WARN__} = sub
{
my #loc = caller(0);
print STDERR "$loc[1]:$loc[2]: warning: ", #_, "\n";
return 1;
};
$SIG{__DIE__} = sub
{
my #loc = caller(0);
print STDERR "$loc[1]:$loc[2]: error: ", #_, "\n";
exit 1;
};
1;
exit with 0 in your customized shell script will turn off "Shell Script Invocation Error"

Can I get vbscript to show a friendly error message?

I'm installing a network printers using vbscript and I want to show a friendly error if the queue doesn't exist or the printer server is unavailable, can I do this with VBScript? My code is below.
Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\printsrv\HPLaser23"
net.SetDefaultPrinter "\\printsrv\HPLaser23"
Many thanks for the help
Steven
Add the line:
On Error Resume Next ' the script will "ignore" any errors
Before your code
and then do an:
if Err.Number <> 0 then
' report error in some way
end if
On Error GoTo 0 ' this will reset the error handling to normal
After your code
It's normally best to try to keep the number of lines of code between the On Error Resume Next and the On Error GoTo 0 to as few as possible, since it's seldom good to ignore errors.

Oracle Forms - Host Command - Return Error Code

Within a Oracle Forms trigger I am using the host command to make a directory on the file server. An example of this part of my code is below:
HOST ('mkdir'||:GLOBAL.DIRECTORY_PATH||'\FERTILIZER\'||ADDY);
I need to have the error code returned to me if the directory is not created on the server. Any suggestions of the code I need to add?
Thank you.
FORM_SUCCESS will return FALSE if the command fails for any reason (unless you're on Windows 95 in which case it will still return TRUE).
HOST('...');
IF NOT FORM_SUCCESS THEN
MESSAGE('something went wrong');
END IF;
If you are looking for the actual OS level error code, then you are out of luck. The aforementioned answer from Jeffrey Kemp
is the best you will get.
If you are having failures, keep in mind that the HOST built-in runs on the machine that actually runs the form (normally the application server). So, your command must be valid for the particular OS of the application server.
Also, and you may have figured this out already, in your example, 'mkdir'||:GLOBAL.DIRECTORY_PATH||'\FERTILIZER\'||ADDY
could result in your command having no space between the command - mkdir and the string, resulting in a failed command.
You still can get the error message by using this statement HOST(vCommand || ' > error.txt');

VBScript Expected End 800A03F6

I am getting this error while trying to run a VBScript (note this is not in a web environment - just running a VBScript on Windows):
Line: [Last line]
Error: Expected 'End'
Code: 800A03F4
Source: Microsoft VBScript compilation error
I think it is an If statement that is not closed correctly with an "End If," but I've gone through every instance of "If" in the code and cannot find the error. Any tips or tools that could help me figure out where/why this error is occurring?
There was an "Else If" - there should be no space there: "Elseif"
http://www.w3schools.com/asp/asp_conditionals.asp
Hopefully this will help someone out in the future.
In VBScript If is not the only token that requires an End. Also look for Function's and Sub's without their appropriate end statements.

Resources