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
  • December 05, 2016, 04:39:12 AM
  • 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: Alias help needed  (Read 3828 times)

fjorge

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Alias help needed
« on: January 14, 2009, 11:08:53 AM »
Hi,

I want to do the following:

I use a program that can be launched with a parameter. The possible values for this parameter are all files in a folder, but without the extension. For example, lets say I have the c:\Parameters folder with the following files:

1st-Parameter.ini
2nd-Parameter.ini
...
Nth-Parameter.ini

And I want to launch the program as:

Program.exe /config 2nd-Parameter

How can I do this with FRR, the way that I type: Program[SPACE] and then I get the list of all files in the C:\Parameters, but then if I type 2, the options are reduced to 2nd-Parameter?

Its kinda hard to explain, so I hope someone understands my problem and can help.

Regards,
Fran

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Alias help needed
« Reply #1 on: January 14, 2009, 01:04:36 PM »
there is a much easier way to do what you want using aliases, *assuming* that you dont actually *need* to have each of the parameters as a file name as you describe.

the method would be to create a new alias, lets call it fjapp

the contents of fjapp alias would look like this:

c:\program files\fjappdir\fjapp.exe param1
c:\program files\fjappdir\fjapp.exe param2
c:\program files\fjappdir\fjapp.exe param3
c:\program files\fjappdir\fjapp.exe param4
c:\program files\fjappdir\fjapp.exe param5

that's it.

now when you want to launch it with the third parameter you could just type into farr: "fjapp 3" and hit enter.

--

if you wanted to get fancier you could give nice labels like:

launch fjapp with parameter 1 (cats) | c:\program files\fjappdir\fjapp.exe param1 blah blah -cats
launch fjapp with parameter 2 (mice) | c:\program files\fjappdir\fjapp.exe param2 "more stuff"
launch fjapp with parameter 3 (doodads) | c:\program files\fjappdir\fjapp.exe param3 "other parameters"
launch fjapp with parameter 4 (ice cream) | c:\program files\fjappdir\fjapp.exe param4 "etc","etc"
launch fjapp with parameter 5 (zebras) | c:\program files\fjappdir\fjapp.exe param5 -a -q

etc.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Alias help needed
« Reply #2 on: January 14, 2009, 01:05:48 PM »
now if you really NEED to have is search a folder for the parameters in the way you are saying, maybe you could explain a little more.. i'm not sure there is really a way to do it yet but there might be a trick to do it, or it might be worth adding a feature for it.

fjorge

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #3 on: January 14, 2009, 03:10:09 PM »
Hi,

Thanks for your reply. The thing is the following:

Just imagine you would like to to have an alias called 'np' that opens a file with, let's say notepad. But you want to restrict the files that you can open with this alias to the ones stored in a certain folder. And imagine that in order to open a file with notepad you were not allowed to pass filename.ext as parameter, but only filename. And additionally, you would like the file list to be dinamically updated while you write the first letters of the file you want to open. For example, as you type np[SPACE] you see the list of all files; if you then press 'a', you see only files that start with 'a'.

Could this be achieved somehow?

Fran

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Alias help needed
« Reply #4 on: January 14, 2009, 04:00:05 PM »
Yes, i believe you could do it using a couple of alias tricks, most notably the "dosearch" alias trick .. it's just a bit weird.. weird enough to wonder if it might be wiser to write a little javascript plugin for farr to do it instead.  Maybe if you could elaborate on the actual use you have in mind and other cases that might use same approach it would crystalize the issue?

fjorge

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #5 on: January 15, 2009, 05:21:31 AM »
The use I have in mind is that I use an ssh client and I can pass it the session I want to open as a parameter. The different sessions that I have preconfigured are stored in a folder under different filenames: 1session.ini, 2session.ini, ... What I want is to be able to type 'ssh' in FARR and to get all possible sessions in the list. Then if I type '2' only sessions starting with 2 will remain in the results. Note that the parameter I have to pass to the client is '2session', not '2session.ini', so there should be a way to delete the extension of the files.

I have tried something like:

Regular Expr Pattern:
^+ssh (.*)

Results:
C:\Archivos de programa\SSH\ssh.exe dosearch D:\Documents and Settings\t148594\Datos de programa\SSH\Sessions\$$1.ini

But it does not seem to work. It only shows the files that match the argument I type after ssh, and not even those in the folder I specify after the dosearch command, but all of them.

Is it not possible to add strings before and after the results? I think this could help me.


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Alias help needed
« Reply #6 on: January 15, 2009, 05:45:37 AM »
ok so this is sort of similar to the work ewemoa did on a putty plugin for farr (see here: http://www.donationc...ex.php?topic=16498.0)

and i think we can see a general use pattern in what you want, that could be useful in other cases.

in general terms, you want to be able to type a keyword and extra search terms that will search a specific folder and do filtering according to the search terms, and then when a file is chosen/launched, you want to launch some specific program and pass the filename (perhaps manipulated to remove the .ini or other stuff) as an arguement.

it seems to me that is something that could have uses beyond ssh and so might be worth figuring out a general solution to, maybe using a plugin, to keep it clean.

let me give it a little more thought about the most sensible way to do it that would be more generally applicable.

the easiest way to do 99% of what you want is to create a new alias, lets call it sshlaunch
with regex pattern as you say: ^+ssh (.*)
then in the results but something like
"dosearch D:\Documents and Settings\t148594\Datos de programa\SSH\Sessions\ +openinssh"

that should make it that typing ssh blah
will show matching filles in the sessions directory, as you want

and it would add a special modifie "+openinssh" to the search string

then the missing piece is that you need a plugin to look for "+openinssh" and know that that means to open the file using
"C:\Archivos de programa\SSH\ssh.exe" and passing the filename (without file extension) as an arguement.

its that last part that you would still need a plugin for.

now this does bring up an interesting idea, which would be to add something to farr that would let you handle this without a plugin, perhaps by letting the alias specify not just a dosearch but some kind of dolaunch statement.  so that the ssh alias would specify how to launch the result after it is triggered..

fjorge

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #7 on: January 15, 2009, 07:54:11 AM »
Yeah, you have caught the point. That is exactly what I would need. Do you think it is doable?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Alias help needed
« Reply #8 on: January 15, 2009, 08:13:43 AM »
oh its definitely doable and i cant see why you'd have to wait more than a week or so for a good solution.. there is a member on the site (nitrix-ud) who can usually find some ingenius way to do things with farr and he could probably find a solution to this without any new coding, but i still think this is a good candidate to figure out a more general solution.

fjorge

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #9 on: January 15, 2009, 10:16:36 AM »
I look forward to seeing this implemented in FARR.

Thanks a lot.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #10 on: January 16, 2009, 06:01:13 AM »
For investigative purposes, would you mind letting us know which SSH implementation you are using?

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #11 on: January 19, 2009, 11:19:55 PM »
Would using a batch file to perform manipulation of session.ini filenames be of any help as a piece of this puzzle?

FWIW, the following removes the .ini portion (along with double quotes) of a string passed as a first argument to the batch file:

Quote
REM based on http://groups.google...msg/923423bf3143fcdd
REM try to manipulate first argument to batch file
SET inifilename=%1
REM remove .ini
SET inifilename=%inifilename:.ini=%
REM remove double quotes
SET inifilename=%inifilename:"=%
ECHO %inifilename%

It may be that using double quotes may be important depending on the file path being manipulated.

fjorge

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Alias help needed
« Reply #12 on: January 20, 2009, 02:52:11 AM »
Quote
Would using a batch file to perform manipulation of session.ini filenames be of any help as a piece of this puzzle?

FWIW, the following removes the .ini portion (along with double quotes) of a string passed as a first argument to the batch file:

Quote
REM based on http://groups.google...msg/923423bf3143fcdd
REM try to manipulate first argument to batch file
SET inifilename=%1
REM remove .ini
SET inifilename=%inifilename:.ini=%
REM remove double quotes
SET inifilename=%inifilename:"=%
ECHO %inifilename%

It may be that using double quotes may be important depending on the file path being manipulated.

Is there any way for FARR to run this batch over the results?