public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* launch shell script from windows explorer
@ 2003-10-31  6:33 Hans Horn
  2003-10-31 10:52 ` Brian Dessent
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Horn @ 2003-10-31  6:33 UTC (permalink / raw)
  To: cygwin

Dear cygwinners,

after searching the archives w/o luck, I'd ask this mailing list.

I'd like to know how I would go about the following:

I'd like to launch a shell script from within windows explorer (either
double-click or via context menu) in a way that:
 - a console (or rxvt window, preferrably) is opened in the folder where the
script resides
 - the script is executed
 - the cnsole stay open after the script has finished

So far I have managed only the first bit (console/rxvt) + script execution,
but the console closes immediately when the script is done.

Any ideas?

H.




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

* Re: launch shell script from windows explorer
  2003-10-31  6:33 launch shell script from windows explorer Hans Horn
@ 2003-10-31 10:52 ` Brian Dessent
  2003-10-31 21:38   ` Hans Horn
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Dessent @ 2003-10-31 10:52 UTC (permalink / raw)
  To: cygwin

Hans Horn wrote:
> 
> Dear cygwinners,

As long as we're not cyglosers...

> after searching the archives w/o luck, I'd ask this mailing list.
> 
> I'd like to know how I would go about the following:
> 
> I'd like to launch a shell script from within windows explorer (either
> double-click or via context menu) in a way that:
>  - a console (or rxvt window, preferrably) is opened in the folder where the
> script resides
>  - the script is executed
>  - the cnsole stay open after the script has finished
> 
> So far I have managed only the first bit (console/rxvt) + script execution,
> but the console closes immediately when the script is done.

I don't know if there's a better way to do this, but you might be able
to achieve the desired effect by adding an explict call to the shell
after the script... for example, the windows command line might resemble

\cygwin\bin\bash -lc ". somescript.sh && bash -i"

This results in two copies of bash being used, but I don't see a way
around that.  If you want the prompt to appear even if the script fails
then change '&&' to ';'.  If you don't want it to start in your home
directory (and you don't care about variables like the path being
initialized for you, and the rest of /etc/profile) then omit the -l
parameter which tells it to be a login shell.  If you want it to not
start in your home directory but still want the path set correctly, then
you'll have to come up with a workaround.  One way might be something
like:

\cygwin\bin\bash -c ". ~/set-path.sh && . ~/somescript.sh && bash -i"

Where set-path.sh is like /etc/profile except without the final "cd
$HOME", and somescript.sh is the thing you want to actually run.

I think others on this list have suggested cleaner ways around this
problem of needing the path setup but not wanting to start in $HOME, so
you might try searching the archives.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

* Re: launch shell script from windows explorer
  2003-10-31 10:52 ` Brian Dessent
@ 2003-10-31 21:38   ` Hans Horn
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Horn @ 2003-10-31 21:38 UTC (permalink / raw)
  To: cygwin

Brian,

thx a lot for helping out here!

I ended up producing the following .reg script that adds the context menu
item "Run script" to files with extersion .sh.

When clicked, it opens an rxvt console in the path of the .sh file and
executes the .sh file.

cheerio,
Hans



"Brian Dessent" <brian@dessent.net> wrote in message
news:3FA2288C.1B256348@dessent.net...
> Hans Horn wrote:
> >
> > Dear cygwinners,
>
> As long as we're not cyglosers...
>
> > after searching the archives w/o luck, I'd ask this mailing list.
> >
> > I'd like to know how I would go about the following:
> >
> > I'd like to launch a shell script from within windows explorer (either
> > double-click or via context menu) in a way that:
> >  - a console (or rxvt window, preferrably) is opened in the folder where
the
> > script resides
> >  - the script is executed
> >  - the cnsole stay open after the script has finished
> >
> > So far I have managed only the first bit (console/rxvt) + script
execution,
> > but the console closes immediately when the script is done.
>
> I don't know if there's a better way to do this, but you might be able
> to achieve the desired effect by adding an explict call to the shell
> after the script... for example, the windows command line might resemble
>
> \cygwin\bin\bash -lc ". somescript.sh && bash -i"
>
> This results in two copies of bash being used, but I don't see a way
> around that.  If you want the prompt to appear even if the script fails
> then change '&&' to ';'.  If you don't want it to start in your home
> directory (and you don't care about variables like the path being
> initialized for you, and the rest of /etc/profile) then omit the -l
> parameter which tells it to be a login shell.  If you want it to not
> start in your home directory but still want the path set correctly, then
> you'll have to come up with a workaround.  One way might be something
> like:
>
> \cygwin\bin\bash -c ". ~/set-path.sh && . ~/somescript.sh && bash -i"
>
> Where set-path.sh is like /etc/profile except without the final "cd
> $HOME", and somescript.sh is the thing you want to actually run.
>
> I think others on this list have suggested cleaner ways around this
> problem of needing the path setup but not wanting to start in $HOME, so
> you might try searching the archives.
>
> Brian
>


begin 666 exec-script.reg
M__Y7`&D`;@!D`&\`=P!S`" `4@!E`&<`:0!S`'0`<@!Y`" `10!D`&D`= !O
M`'(`( !6`&4`<@!S`&D`;P!N`" `-0`N`# `, `-``H`#0`*`%L`2 !+`$4`
M60!?`$,`3 !!`%,`4P!%`%,`7P!2`$\`3P!4`%P`<P!H`%\`80!U`'0`;P!?
M`&8`:0!L`&4`7 !S`&@`90!L`&P`7 `P`'(`=0!N`"T`<P!C`'(`:0!P`'0`
M70`-``H`0 `]`"(`4@!U`&X`( !3`&,`<@!I`' `= `B``T`"@`-``H`6P!(
M`$L`10!9`%\`0P!,`$$`4P!3`$4`4P!?`%(`3P!/`%0`7 !S`&@`7P!A`'4`
M= !O`%\`9@!I`&P`90!<`',`: !E`&P`; !<`# `<@!U`&X`+0!S`&,`<@!I
M`' `= !<`&,`;P!M`&T`80!N`&0`70`-``H`0 `]`"(`0P`Z`%P`7 !C`'D`
M9P!W`&D`;@!<`%P`8@!I`&X`7 !<`'(`> !V`'0`+@!E`'@`90`@`"T`8@!A
M`&,`:P!S`' `80!C`&4`:P!E`'D`( !>`&@`( `M`&(`9P`@`&(`; !A`&,`
M:P`@`"T`9@!G`" `=P!H`&D`= !E`" `+0!C`'(`( !Y`&4`; !L`&\`=P`@
M`"T`<P!R`" `+0!G`&4`;P!M`&4`= !R`'D`( `Y`# `> `W`#0`*P`P`"L`
M, `@`"T`<P!L`" `,0`P`# `, `@`"T`9@!N`" `7 `B`$P`=0!C`&D`9 !A
M`" `0P!O`&X`<P!O`&P`90`M`#D`8@!<`"(`( `M`&P`<P`@`"T`90`@`"\`
M=0!S`'(`+P!B`&D`;@`O`&(`80!S`&@`( `M`"T`; !O`&<`:0!N`" `+0!C
M`" `7 `B`&,`9 `@`%P`7 !<`"(`8 !C`'D`9P!P`&$`= !H`" `+0!U`" `
M)P`E`#$`)P`O`"X`+@!@`%P`7 !<`"(`.P`@`"<`)0`Q`"<`( `F`"8`( !B
;`&$`<P!H`" `+0!I`%P`(@`B``T`"@`-``H`
`
end



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

end of thread, other threads:[~2003-10-31 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-31  6:33 launch shell script from windows explorer Hans Horn
2003-10-31 10:52 ` Brian Dessent
2003-10-31 21:38   ` Hans Horn

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).