PDA

View Full Version : sfxcl return value 0 on failure?


smagee
08-29-2005, 06:40 AM
The documentation and thread in the forum that I've read say that sfxcl should return a non-zero if the run has any errors and 0 if none. What I want to know, I guess, is what exactly constitutes an 'error'? My error handling just failed to detect a failure to transmit the file because sfxcl returned 0 when it couldn't find it's configuration directory. I get a nice message:

A configuration path has not been specified or cannot be found.

Please use the /F command line switch, or run the application in GUI mode first.

and a 0 return value, which my code interpreted as a successful transmission of the file which it clearly was not. So, what are the cases where sfxcl will NOT transmit and WILL return 0? I would like to be able to have my calling code report failure to transmit any time there is actually a failure to transmit. I've jimmied it to watch for this message and report failure in this case. Questions: Should I need to do this (i.e., is this a bug or a feature)? Where else do I need to check something besides the return value to see if the file actually went?

bocks
08-29-2005, 09:36 AM
Hello smagee,A configuration path has not been specified or cannot be found.

Please use the /F command line switch, or run the application in GUI mode first.

and a 0 return value, which my code interpreted as a successful transmission of the file which it clearly was not. So, what are the cases where sfxcl will NOT transmit and WILL return 0?
...
Questions: Should I need to do this (i.e., is this a bug or a feature)? Where else do I need to check something besides the return value to see if the file actually went?These are good questiona, as they reflect on many aspects of sfxcl. Normally, sfxcl will return a non zero value when a file transfer fails. It does not report a specific error code, only that a failure occured. In this instance, it could not find configuration information from SecureFX, so it displayed an error message and then closed normally - returning zero. Since no file transfer failed, it returned the default value for successful execution of sfxcl. From your message it sounds like you expect sfxcl to return a non-zero on any error - not just when a transfer is attempted and failed. Is this correct?

Would you be able to tell me the exact command line that is being used to call sfxcl? Please star out (***) sensitive information, such as passwords or passphrases and usernames.

Can you tell me what version of SecureFX you are using (including the build number)?

Typically, we see the error asking sfxcl to e run with a /F, sfxcl is either being run under an account that has not executed the SecureFX GUI ( in older versions), or when using sfxcl from an account that does not have a Config folder in the default location (when using newer versions).

In the current version of SecureFX, you can resolve this by copying the SecureFX Config folder to a location that is accessible to the account being used to run sfxcl and specifying this using the /F option.

In older versions of SecureFX, this is more problematic, as configuration information is stored in the registry under the HKEY_CURRENT_USER hive. There are a couple of work-arounds for this. If this is a scheduled task, then you can specify a user account to be used when the script is executed, when you create the task. If your script is going to be run by a different user, then the following instruction may help. They describe how to modify the registry to allow you to alllow sfxcl to be run by a system user.

Please let me know how this works for you.

Thanks,

-bocks

================

The instructions that follow describe the process that needs to be followed in order to successfully run SFXCL as the SYSTEM user.

NOTE: Before proceeding make sure you have configured the Global Configuration in SecureFX as desired. If you later make changes to the Global Options, please follow this same procedure to ensure that the SYSTEM user gets updated with the changes to SecureFX's global configuration. Make sure that you are currently logged on to the machine as the user who has already run SecureFX and has set up the sessions needed for sfxcl to transfer files. If you are specifying a URL such as
sftp://username:password@OurSFTPServer/pub/vim/vim57as part of the connection information to the sfxcl.exe app, then it is only necessary to have run SecureFX for the first time, and creating sessions is optional.

Verify that you can (as the currently logged on user) run SecureFX and connect successfully to the remote machine(s) necessary.

Exit the SecureFX application.

Start "regedit.exe", navigate to:
HKEY_CURRENT_USER\Software\VanDyke\SecureFX

Open the "Registry" menu, and select "Export Registry File..."

In the "Export Registry File" dialog, make sure the "Selected branch" option is selected.

Save the .REG file to a known location and filename

Open the saved .REG file in your editor of choice (Notepad, for example)

Perform a search and replace operation, replacing all instances of "HKEY_CURRENT_USER" with "HKEY_USERS\.DEFAULT"

Save the changed file, and using Windows Explorer, browse to the .REG file, right-click on the file and choose "Merge".

A message should indicate the file has been entered into the registry.
Now sfxcl can be run as the SYSTEM user, sharing all session information with the user from which the SecureFX registry key was exported.

smagee
08-29-2005, 11:00 AM
Hi bocks-

Hello smagee,These are good questiona, as they reflect on many aspects of sfxcl. Normally, sfxcl will return a non zero value when a file transfer fails. It does not report a specific error code, only that a failure occured. In this instance, it could not find configuration information from SecureFX, so it displayed an error message and then closed normally - returning zero. Since no file transfer failed, it returned the default value for successful execution of sfxcl. From your message it sounds like you expect sfxcl to return a non-zero on any error - not just when a transfer is attempted and failed. Is this correct?


One of my questions was 'Is this expected behavior?'. From the view of my calling code, there was a failure - I told sfxcl to send the file and it didn't. You are correct, my preference would be for sfxcl to return a non-zero result in any case where the file didn't get sent. However, I was aware that returning zero in this case might be designed behavior - the transmission never started, so it didn't fail. So what I need to know is the other cases where I might not actually send the file though sfxcl returns a 0.


Would you be able to tell me the exact command line that is being used to call sfxcl? Please star out (***) sensitive information, such as passwords or passphrases and usernames.


c:\program files\securefx\sfxcl.exe /NoPrompt /RetryCount 1 <file>.zip sftp://<uid>:<pwd>@<host>/<file>.zip


Can you tell me what version of SecureFX you are using (including the build number)?


sfxcl version 3.0.1 (build 869)
SSH2Core version 3.1.0.545


Typically, we see the error asking sfxcl to e run with a /F, sfxcl is either being run under an account that has not executed the SecureFX GUI ( in older versions), or when using sfxcl from an account that does not have a Config folder in the default location (when using newer versions).


That is exactly the case - I forgot to run through the config before executing the calling program. So I was surprised when the calling program reported success but the files didn't show on the server. Poking around, I realized that the file actually hadn't been sent and why. I've now changed my code to read the output stream, detect this case, and generate a useful error saying that sfxcl isn't configured properly. Are there other cases where sfxcl might exit with 0 status but not actually send the file? If I only want to report success when the file is actually sent, I need to know all the cases where transmission wasn't attempted as well as the cases where the transmission failed.

bocks
09-01-2005, 09:16 AM
Hi smagee,The documentation and thread in the forum that I've read say that sfxcl should return a non-zero if the run has any errors and 0 if none. What I want to know, I guess, is what exactly constitutes an 'error'? My error handling just failed to detect a failure to transmit the file because sfxcl returned 0 when it couldn't find it's configuration directory.I just received your message. I apologize for the delay in replying, but I needed to confirm exactly what should and should not return error codes in sfxcl.

The expected behavior of sfxcl is to return an error for all errors or transfer failures. The exception would be when you use a command line option that modifies the default behavior. An example would be using the "/Overwrite never" command-line option to prevent a transfer form overwriting an existing file. Failure to transer a file that met this criteria would not constitue an error. This defines the behavior that you have seen as a bug. I have created an incident report and forwarded it to the SecureFX product manager and our developers.

We will be posting to this Forum when a fix becomes available, but if you would like to be notified privately, I will need to get your contact information. Please send an email to me at Support@vandyke.com with a subject of Attn: Shannon re: Forums thread #984. I will then add your contact information to the notification list for this bug.

Once I have some more information, I will either contact you or post back to the Forums to let you know what is happening with regards to this bug.

Thank you,

-bocks