Adding new custom command parameter and apply error

Advertisement

pstein
Joined:
Posts:
22

Adding new custom command parameter and apply error

I want to add a new, own custom command

dos2unix <thisfile> <thisfile>

Obviously the CR/LF are replaced in-place by the unix style

What do I have to enter for <thisfile>?

Is this suitable:

dos2unix "!" "!"

?

When try to apply the command above to a certain file a dialog pops up telling me:

"Current SFTP-3 session does not support command you request. Separate shell session may be opened to process the command. Do you want to open separate shell session?"

Hm, why this?

I don't want another session. How can I achieve the execution of the dos2unix command in the current session otherwise?

Peter

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Adding new custom command parameter and apply error

The command is fine.
The prompt you are getting simply means that SFTP does not support executing shell commands. So WinSCP needs to open another shell session to perform the command.

What maybe confused you if term command. In the prompt is does not refer to your specific "dos2unix" command, but generally to "custom command" command/feature.

Reply with quote

pstein
Joined:
Posts:
22

Re: Adding new custom command parameter and apply error

martin wrote:

The command is fine.
The prompt you are getting simply means that SFTP does not support executing shell commands. So WinSCP needs to open another shell session to perform the command.

What maybe confused you if term command. In the prompt is does not refer to your specific "dos2unix" command, but generally to "custom command" command/feature.

Hmm, I don't understand. If the "command is fine" as you said why is it failing? After applying it to a file I got an error popup:

Error executing custom command 'dos2unix "!" "!" on file 'dotest'.
Command 'dos2unix "dotest" "dotest"'
failed with return code 0 and error message
dos2unix: converting file dotest to UNIX format ...
dos2unix: converting file dotest to UNIX format ....

What's wrong?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Adding new custom command parameter and apply error

pstein wrote:

Error executing custom command 'dos2unix "!" "!" on file 'dotest'.
Command 'dos2unix "dotest" "dotest"'
failed with return code 0 and error message
dos2unix: converting file dotest to UNIX format ...
dos2unix: converting file dotest to UNIX format ....
Because the dos2unix obviously prints its progress on error output. That's why WinSCP think it fails, although it does not.

Reply with quote

pstein
Joined:
Posts:
22

Re: Adding new custom command parameter and apply error

martin wrote:

pstein wrote:

Error executing custom command 'dos2unix "!" "!" on file 'dotest'.
Command 'dos2unix "dotest" "dotest"'
failed with return code 0 and error message
dos2unix: converting file dotest to UNIX format ...
dos2unix: converting file dotest to UNIX format ....
Because the dos2unix obviously prints its progress on error output. That's why WinSCP think it fails, although it does not.

Maybe WinSCP can redirect the stderr output so that no error msg is shown.
The user should not be confused because of the error msg although the actual command was executed successfully.

Is this possible (in the next release)?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Adding new custom command parameter and apply error

pstein wrote:

Maybe WinSCP can redirect the stderr output so that no error msg is shown.
The user should not be confused because of the error msg although the actual command was executed successfully.

Is this possible (in the next release)?
WinSCP should not do this implicitly, because for most commands output on stderr indicates an error. You can redirect the output explicitly:
dos2unix "!" "!" 2> /dev/null
Last edited by martin on 2014-01-24; edited 1 time in total

Reply with quote

dhall
Guest

Re: Adding new custom command parameter and apply error

martin wrote:

pstein wrote:

Maybe WinSCP can redirect the stderr output so that no error msg is shown.
The user should not be confused because of the error msg although the actual command was executed successfully.

Is this possible (in the next release)?
WinSCP should not do this implicitly, because for most commands output on stderr indicates an error. You can redirect the output explicitly:
dos2unix "!" "!" > /dev/null

Martin, I have tried your redirect solution several times, and I get the error message dialog displayed. You are correct that the files themselves are converted, but the Error is displayed as such:
Command 'dos2unix "16-JAN-14.TXT" "16-JAN-14.TXT" > /dev/null'failed with return code 0 and error message
dos2unix: converting file 16-JAN-14.TXT to UNIX format ...
Do you have any suggestions?
I am using version 4.3.5 (build 1463)

Reply with quote

x_man
Guest

script work fine, but WinSCP show Error with Error code 0

I run perl script as a Custom command (like this: perl -e '[script code]' !&)

And I got situation like this: script work fine, but WinSCP show Error window with some text and Error code 0.
I was confused!

...but after review [script code] I find some string like this "print STDERR $str" instead "print STDOUT $str" (for normal work!).


=> WinSCP show Error window just if you [script code] print STDERR!
...with any Return Error Code.

Reply with quote

Advertisement

You can post new topics in this forum