Topic "Adding new custom command parameter and apply error"

Author Message
pstein
[View user's profile]

Joined: 2006-10-18
Posts: 22
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
pstein
[View user's profile]

Joined: 2006-10-18
Posts: 22
prikryl 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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
pstein
[View user's profile]

Joined: 2006-10-18
Posts: 22
prikryl 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)?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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
dhall

Guest


prikryl 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:
Code:
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)
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
I have corrected my answer. Note the 2>
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License