public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Running a command in a specific directory
@ 2022-03-22 22:35 Piotr Gliźniewicz
  2022-03-22 22:40 ` Eliot Moss
  2022-03-23  7:21 ` Brian Inglis
  0 siblings, 2 replies; 3+ messages in thread
From: Piotr Gliźniewicz @ 2022-03-22 22:35 UTC (permalink / raw)
  To: cygwin

Hi,

I'm trying to run a command at a specific "Windows" path. Basically 
something similar to what chere does for bash, but I want to execute ls 
in bash for a specific directory. I've tried variations of what chere 
leaves in the registry:

C:\cygwin64\bin\bash.exe -c "/bin/xhere /bin/bash.exe '%L'"

Adding simply `-c ls` didn't work.

To start with something simpler I've launched bash and tried just to 
guess what xhere want's, but I don't really know what's happening. I 
couldn't find any help for xhere.

/cygdrive/c
$ /bin/xhere '/bin/bash.exe -c ls' d:
/bin/xhere: line 38: [: too many arguments
/bin/xhere: line 41: [: too many arguments
/bin/xhere: line 64: [: too many arguments
Starting /bin/bash.exe -c ls
-/bin/bash: ls: command not found

/cygdrive/c
$ /bin/xhere "/bin/bash.exe -c ls" d:
/bin/xhere: line 38: [: too many arguments
/bin/xhere: line 41: [: too many arguments
/bin/xhere: line 64: [: too many arguments
Starting /bin/bash.exe -c ls
-/bin/bash: ls: command not found

Any hints, how to properly pass `/bin/bash.exe -c ls` to xhere?

--
Regards,
Piotr Gliźniewicz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Running a command in a specific directory
  2022-03-22 22:35 Running a command in a specific directory Piotr Gliźniewicz
@ 2022-03-22 22:40 ` Eliot Moss
  2022-03-23  7:21 ` Brian Inglis
  1 sibling, 0 replies; 3+ messages in thread
From: Eliot Moss @ 2022-03-22 22:40 UTC (permalink / raw)
  To: Piotr Gliźniewicz, cygwin

On 3/22/2022 6:35 PM, Piotr Gliźniewicz wrote:
> Hi,
> 
> I'm trying to run a command at a specific "Windows" path. Basically something similar to what chere 
> does for bash, but I want to execute ls in bash for a specific directory. I've tried variations of 
> what chere leaves in the registry:
> 
> C:\cygwin64\bin\bash.exe -c "/bin/xhere /bin/bash.exe '%L'"
> 
> Adding simply `-c ls` didn't work.
> 
> To start with something simpler I've launched bash and tried just to guess what xhere want's, but I 
> don't really know what's happening. I couldn't find any help for xhere.
> 
> /cygdrive/c
> $ /bin/xhere '/bin/bash.exe -c ls' d:
> /bin/xhere: line 38: [: too many arguments
> /bin/xhere: line 41: [: too many arguments
> /bin/xhere: line 64: [: too many arguments
> Starting /bin/bash.exe -c ls
> -/bin/bash: ls: command not found
> 
> /cygdrive/c
> $ /bin/xhere "/bin/bash.exe -c ls" d:
> /bin/xhere: line 38: [: too many arguments
> /bin/xhere: line 41: [: too many arguments
> /bin/xhere: line 64: [: too many arguments
> Starting /bin/bash.exe -c ls
> -/bin/bash: ls: command not found
> 
> Any hints, how to properly pass `/bin/bash.exe -c ls` to xhere?

I'm not familiar with xhere; I would just do something like:

C:\cygwin64\bin\bash.exe -c "cd place/I/want/to/be; ls"

Cheers - EM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Running a command in a specific directory
  2022-03-22 22:35 Running a command in a specific directory Piotr Gliźniewicz
  2022-03-22 22:40 ` Eliot Moss
@ 2022-03-23  7:21 ` Brian Inglis
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Inglis @ 2022-03-23  7:21 UTC (permalink / raw)
  To: cygwin

On 2022-03-22 16:35, Piotr Gliźniewicz wrote:
> I'm trying to run a command at a specific "Windows" path. Basically 
> something similar to what chere does for bash, but I want to execute ls 
> in bash for a specific directory. I've tried variations of what chere 
> leaves in the registry:
> C:\cygwin64\bin\bash.exe -c "/bin/xhere /bin/bash.exe '%L'"
> Adding simply `-c ls` didn't work.
> To start with something simpler I've launched bash and tried just to 
> guess what xhere want's, but I don't really know what's happening. I 
> couldn't find any help for xhere.
> /cygdrive/c
> $ /bin/xhere '/bin/bash.exe -c ls' d:
> /bin/xhere: line 38: [: too many arguments
> /bin/xhere: line 41: [: too many arguments
> /bin/xhere: line 64: [: too many arguments
> Starting /bin/bash.exe -c ls
> -/bin/bash: ls: command not found
> /cygdrive/c
> $ /bin/xhere "/bin/bash.exe -c ls" d:
> /bin/xhere: line 38: [: too many arguments
> /bin/xhere: line 41: [: too many arguments
> /bin/xhere: line 64: [: too many arguments
> Starting /bin/bash.exe -c ls
> -/bin/bash: ls: command not found
> Any hints, how to properly pass `/bin/bash.exe -c ls` to xhere?

$ file `which xhere`
/usr/bin/xhere: Bourne-Again shell script, ASCII text executable
$ head `which xhere`
#!/bin/bash
# Have to use bash; can't get ash to "exec -l"
# Separate script from chere to avoid need for argument parsing
#
# first arg is shell
# second arg is the path
...

Can't do that: xhere expects shell path /bin/*sh* and directory path and 
runs under bash so it can run exec -l to exec shell as login shell after 
cd dir.

Starting XWin Server from a shortcut uses:

C:\...\cygwin...\bin\run.exe --quote /bin/bash -l -c "cd; exec 
/bin/startxwin"

so you could base a commnad line on that.

You could also install and use Cygwin-X with a GUI file manager like 
PcManFM, or a text version like Midnight Commander (package mc).

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-23  7:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 22:35 Running a command in a specific directory Piotr Gliźniewicz
2022-03-22 22:40 ` Eliot Moss
2022-03-23  7:21 ` Brian Inglis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).