using cd with output of external programm
Moderators: Hacker, petermad, Stefan2, white
using cd with output of external programm
Hi all,
at the moment I have a button which starts a external program which puts the command eg. cd c:/temp/testdir into the clipboard. I have to switch to the commandline and use ctrl-c to copy this content. Than I have to hit return.
I'm looking for a method to feed the output which is not necessarily the clipboard but also a file or simply written to stdout.
The easyest way I suppose is a kind of substitute like in bash
CD $(prg to execute)
where first the prg_to_execute will executed and its output feed to CD
Is there such a mechanism in TC ??
Also other solutions are greatly appreciated!
at the moment I have a button which starts a external program which puts the command eg. cd c:/temp/testdir into the clipboard. I have to switch to the commandline and use ctrl-c to copy this content. Than I have to hit return.
I'm looking for a method to feed the output which is not necessarily the clipboard but also a file or simply written to stdout.
The easyest way I suppose is a kind of substitute like in bash
CD $(prg to execute)
where first the prg_to_execute will executed and its output feed to CD
Is there such a mechanism in TC ??
Also other solutions are greatly appreciated!
If you are the coder of the external program then you can do so via TC's command line, just run TC using a command line similar to this
Code: Select all
%COMMANDER_PATH%\TOTALCMD.EXE /O /L=your_prog_output
I don't understand exactly what you are searching for, but if you search a handy CD-Tool (change directory tool) for TC then take a look at "XCD":
http://mitglied.multimania.de/matbal/
Peter
http://mitglied.multimania.de/matbal/
Peter
TC 10.xx / #266191
Win 10 x64
Win 10 x64
Hi Sir_SiLvA,
thanks for the quick reply.
To make it clear:
TC is already runnig, than I click a button from the button bar. This action should start an external programm. Magicaly it generates a path to a directory. How can I force the running TC to change to this directory ??
Hope this is clear enough to prevent unecessary work
have fun
Dexli
thanks for the quick reply.
Maybe I'm a little bit unspecific because that is not what I'm asking for.Sir_SiLvA wrote:Learn to read the Helpfile of TC please.
Start TC -> Press F1 -> 4.a -> Params /L & /R are what you are looking for...
To make it clear:
TC is already runnig, than I click a button from the button bar. This action should start an external programm. Magicaly it generates a path to a directory. How can I force the running TC to change to this directory ??
Hope this is clear enough to prevent unecessary work

have fun
Dexli
I think dexli needs another thing - he asked how to use output of one program as input for another.
It may be done using following way:
1. redirect output path to temporary file:
2. read temp file to envvar:
3. use envvar to change dir in TC (parameter /O tells to TC not to start new instance but to change dir in already started one):
Steps 2 and 3 must be done in single batch file.
It may be done using following way:
1. redirect output path to temporary file:
Code: Select all
input.exe > %temp%\my_new_path.txt
Code: Select all
set /p my_new_path= < %temp%\my_new_path.txt
Code: Select all
%COMMANDER_PATH%\TOTALCMD.EXE /O /L=%my_new_path%
Last edited by MVV on 2011-05-10, 13:58 UTC, edited 3 times in total.
Hi ts4242,
thanks for your reply.
Have fun
Dexli
thanks for your reply.
as stated before, that is not what I'm looking for. I don't want to fire up another TC. I just want to force the active one to change the directory.ts4242 wrote:If you are the coder of the external program then you can do so via TC's command line, just run TC using a command line similar to thisCode: Select all
%COMMANDER_PATH%\TOTALCMD.EXE /O /L=your_prog_output
Have fun
Dexli
Hi Peter,
Have fun
Dexli
Sorry but this functionality is included in TC ( the asterisk beneth the actual path) and this is not the thing.Peter wrote:I don't understand exactly what you are searching for, but if you search a handy CD-Tool (change directory tool) for TC then take a look at "XCD":
http://mitglied.multimania.de/matbal/
Peter
Have fun
Dexli
Hi MVV
Eg. lets say I have a button and in the Command: field I use
CD c:\a\long\path\to\a\directory
Than every time I click this button TC will set the actual directory of the active window to c:\a\long\path\to\a\directory
What I'm looking for is to find a way to call an external prg to provide another path instead of c:\a\long\path\to\a\directory
If TC would provide a command substitution like the BASH one would use
CD $(c:\path\to\external\prg)
The mechanism would be:
first the c:\path\to\external\prg would be called and its out put would be used as (a) parameter(s) to CD which will be executed than.
I know that such a mechanism do not exist in TC but maybe something similar.
I hope now I made clear what I'm looking for.
Have fun
Dexli
Not quite correct. The output of the program should be used as the parameter for a TC command.MVV wrote:I think dexli needs another thing - he asked how to use output of one program as input for another.
Eg. lets say I have a button and in the Command: field I use
CD c:\a\long\path\to\a\directory
Than every time I click this button TC will set the actual directory of the active window to c:\a\long\path\to\a\directory
What I'm looking for is to find a way to call an external prg to provide another path instead of c:\a\long\path\to\a\directory
If TC would provide a command substitution like the BASH one would use
CD $(c:\path\to\external\prg)
The mechanism would be:
first the c:\path\to\external\prg would be called and its out put would be used as (a) parameter(s) to CD which will be executed than.
I know that such a mechanism do not exist in TC but maybe something similar.
I hope now I made clear what I'm looking for.
Have fun
Dexli
You need to pass path to envvar and then to call TC with /O parameter. Also read about /S and /T parameters - sometimes they're useful too.
Also you may download little tool called TCMC and use it to change path in TC - it is small so should be loaded faster than temporary second TC instance.
Also you may download little tool called TCMC and use it to change path in TC - it is small so should be loaded faster than temporary second TC instance.
Problem solved :lol:
Hi all,
thanks for your help I have found a solution which completly sattify my needs.
to give back a litte here the skelleton of a perl script which will be called by a button from the button bar.
Additonal info:
I use the cygwin environment *, therefor I have to use run.exe to start a windows prg. Also the #! /usr/bin/perl shebang will be different if you are not running cygwin.
*http://www.cygwin.com/
edit: adding information about quoting the the path
thanks for your help I have found a solution which completly sattify my needs.

to give back a litte here the skelleton of a perl script which will be called by a button from the button bar.
Code: Select all
#! /usr/bin/perl -w
# proof of concept for using external prg
# to change the actual director of total commander
# Because of the cygwin environment the $Run is
# necessary.
my $Run = 'c:\Programme\cygwin\bin\run.exe ';
# Path to totalcommander
my $TC='c:\Programme\totalcmd\TOTALCMD.EXE ';
# get some input
print "Clientnumber: ";
my $a = <STDIN>;
$a =~s/\r*\n//;
# construct the path consisting of
# a const part and the input
$p ='d:\Region\Customers\Client_'.$a;
# construct the string which should be executed
# instead of using /L= one can use /R= or just
# the path to a directory. Maybe it is a
#good idea to enclose the $p value in
#double quotes because they might
#contain spaces
# .'"'.$p.'"'
my $str = $Run .$TC .'/O /L='.$p;
#show what is passed to exec
print $str,"\n";
# at least doit
exec $str;
I use the cygwin environment *, therefor I have to use run.exe to start a windows prg. Also the #! /usr/bin/perl shebang will be different if you are not running cygwin.
*http://www.cygwin.com/
edit: adding information about quoting the the path