Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 25, 2016, 03:53:36 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: How to copy command line output in an alias?  (Read 912 times)

jolleyjoe

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
How to copy command line output in an alias?
« on: February 03, 2016, 11:44:36 AM »
Hi everyone! Loving FARR.

I am having some issues using a pipe ("|") within an alias:

Quote
echo test |clip

but the pipe has a special meaning within an alias.

Is there a way I can escape the pipe?
Is there another way I can easily copy the output of a command within an alias? I looked into copyclip "Special/Virtual Launch Strings/Commands", but could not figure out a solution.

Thanks in advance for any help!

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,248
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #1 on: February 03, 2016, 11:48:16 AM »
try using double quotes to surround the commandline.

jolleyjoe

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #2 on: February 03, 2016, 12:04:08 PM »
try using double quotes to surround the commandline.

Thanks for the lightning fast response!

Trying this as the alias:

Code: Text [Select]
  1. "echo $$1 | clip"

Running `test` shows `echo $$1` without the `| clip` part, so it seems that it may still not be escaping the pipe ("|") symbol properly. Any other suggestions?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,248
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #3 on: February 03, 2016, 12:22:34 PM »
I'm going to have to look into the escaping of pipe character -- i thought that putting it in double quotes should work, but it's definitely possible I'm wrong.

But getting back to what you are trying to do..

Can you elaborate a little more on exactly what you are trying to do .. FARR does have commands for copying things to the clipboard, etc.

jolleyjoe

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #4 on: February 03, 2016, 01:05:26 PM »
I'm going to have to look into the escaping of pipe character -- i thought that putting it in double quotes should work, but it's definitely possible I'm wrong.

But getting back to what you are trying to do..

Can you elaborate a little more on exactly what you are trying to do .. FARR does have commands for copying things to the clipboard, etc.

I have a script that will fetch results of a query, for example:

Code: Text [Select]
  1. > path/to/script 20 ft to yards
  2. 20 feet = 6.6 yards

I'd like to get that output into my clipboard without adding the clipping functionality to the script itself. Please let me know if I can help clarify further.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,248
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #5 on: February 03, 2016, 01:17:30 PM »
ok good question..

heres what i THINK should work, an alias result that looked something like this:

appcap "path/to/script 20 ft to yards";;; copyclip %lastappcap%

i have not tested that, so i can't be entirely sure, and if you can't get that to work i will make sure it can be done somehow.

but here's how that's SUPPOSED to work:
The appcapp command should launch the specified program, and capture it's output in %lastappcap%.
Then the ;;; separates the next command to run, which tells farr to copy the contents of %lastappcap% to clipboard.

If that is all too messy, i might add a new appcap like appcclip to run an app and copy result to clipboard.

And, before you try making that work, you might try the simpler:
appcapappendmemo path/to/script 20 ft to yards

See here for an example: http://www.donationc...ndex.php?topic=28136

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,248
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #6 on: February 03, 2016, 01:17:55 PM »
You'll find all these weird special commands in the help page under "Special/Virtual Launch Strings/Commands"

jolleyjoe

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: How to copy command line output in an alias?
« Reply #7 on: February 03, 2016, 07:10:13 PM »
ok good question..

heres what i THINK should work, an alias result that looked something like this:

appcap "path/to/script 20 ft to yards";;; copyclip %lastappcap%

i have not tested that, so i can't be entirely sure, and if you can't get that to work i will make sure it can be done somehow.

but here's how that's SUPPOSED to work:
The appcapp command should launch the specified program, and capture it's output in %lastappcap%.
Then the ;;; separates the next command to run, which tells farr to copy the contents of %lastappcap% to clipboard.

If that is all too messy, i might add a new appcap like appcclip to run an app and copy result to clipboard.

And, before you try making that work, you might try the simpler:
appcapappendmemo path/to/script 20 ft to yards

See here for an example: http://www.donationc...ndex.php?topic=28136

All of them gave me the same error:

Trying appcapappendmemo with double quotes:
Code: Text [Select]
  1. appcapappendmemo "path/to/script $$1"

and appcapappendmemo without double quotes:
Code: Text [Select]
  1. appcapappendmemo path/to/script $$1

Trying appcap:
Code: Text [Select]
  1. appcap "C:\path\to\script $$1";;; copyclip %lastappcap%

In the results, it would show me (note unmatched double-quote):
Code: Text [Select]
  1. script $$1";;; copyclip

I tried sending:

Code: Text [Select]
  1. alias time in taiwan

All of the above shows displays this error:

Code: Text [Select]
  1. Error launching redirected commandline program: ("path\to\script time in taiwan")

For reference, this command works fine in cmd.exe:
Code: Text [Select]
  1. path\to\script time in taiwan

Please let me know if you have any other suggestions!