Topic "Custom command patterns and !"

Author Message
tristan
[View user's profile]

Joined: 2014-09-18
Posts: 1
WinSCP version 5.5.5

I was using the commander GUI to create a custom command to grep for a password in files within multiple directories.
I used this:
Code:
grep -H -r "!?Search for text:?!" *  | cut -d: -f1 >> grep-!?Name of results file?!.txt


And then I think I killed our entire server by searching for a password with an exclamation point in it.

Can anyone verify whether or not the middle exclamation point in "!?pass!word?!" would be read as an exclamation point, or would winscp expand it into a file name unless it was escaped, or something else? Should I surround the search phrase by single quotes instead of double?

Also, can anyone clarify if !& expands to just selected files, or will it expand to a selected directory, too?

Thanks.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Quote:
Can anyone verify whether or not the middle exclamation point in "!?pass!word?!" would be read as an exclamation point, or would winscp expand it into a file name unless it was escaped, or something else? Should I surround the search phrase by single quotes instead of double?


The exclamation mark terminates the "prompt" pattern, so in !?pass!word?!, the !?pass! is replaced by the user input, word? is used literally and ! is replaced by the name of selected file. Quotes have no effect on the custom commands.

Quote:
Also, can anyone clarify if !& expands to just selected files, or will it expand to a selected directory, too?

See Apply to directories option:
https://winscp.net/eng/docs/ui_customcommand
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