|
View:
New views
18 Messages
—
Rating Filter:
Alert me
|
|
|
How do I make scripts my PC executableI have some scripts I'd like to run without starting cygwin and typing in their paths. Is there a way to make windows recognize that a file is a bash/python script and run them like as if I ran them in cygwin? I'd like to just be able to doubleclick them in windows explorer. Is this possible? (I'm using bash and python scripts)
|
|
|
RE: How do I make scripts my PC executableOn 29 August 2007 17:59, zip184 wrote:
> I have some scripts I'd like to run without starting cygwin and typing in > their paths. Is there a way to make windows recognize that a file is a > bash/python script and run them like as if I ran them in cygwin? I'd like > to just be able to doubleclick them in windows explorer. Is this possible? > (I'm using bash and python scripts) Windoze doesn't understand about shebangs (the #! line at the start of the script), and bases all its decisions on the filename extension. So, if you name your scripts according to the pattern '*.sh', and make sure to chmod a+x them, you can double-click in explorer. The first time you do that, windows will complain it doesn't know what to do with a sh file, and offer you the choice of looking up on the web or selecting from a list which program you want to open .sh files with; choose the select-from-a-list option, when the list appears click the browse button, find your way to cygwin\bin\bash.exe and select that. Make sure "Always use this program" is ticked, enter a nice descriptive name such as "Bash script" in the description box, OK it and away you go! cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/ |
|
|
Re: How do I make scripts my PC executableOn 2007-08-29, Dave Korn wrote:
> On 29 August 2007 17:59, zip184 wrote: > > > I have some scripts I'd like to run without starting cygwin and typing in > > their paths. Is there a way to make windows recognize that a file is a > > bash/python script and run them like as if I ran them in cygwin? I'd like > > to just be able to doubleclick them in windows explorer. Is this possible? > > (I'm using bash and python scripts) > > Windoze doesn't understand about shebangs (the #! line at the start of the > script), and bases all its decisions on the filename extension. So, if you > name your scripts according to the pattern '*.sh', and make sure to chmod a+x > them, you can double-click in explorer. > > The first time you do that, windows will complain it doesn't know what to do > with a sh file, and offer you the choice of looking up on the web or selecting > from a list which program you want to open .sh files with; choose the > select-from-a-list option, when the list appears click the browse button, find > your way to cygwin\bin\bash.exe and select that. Make sure "Always use this > program" is ticked, enter a nice descriptive name such as "Bash script" in the > description box, OK it and away you go! That won't run the script in the same environment that it would get when run from a Cygwin login shell, though, will it? I would think the program might have to be a .bat file that contains something like this (untested): C:\cygwin\bin\bash.exe --login -c %1 Regards, Gary -- 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/ |
|
|
RE: How do I make scripts my PC executablezip184 wrote:
> I have some scripts I'd like to run without starting cygwin and > typing in their paths. Is there a way to make windows recognize that > a file is a bash/python script and run them like as if I ran them in > cygwin? I'd like to just be able to doubleclick them in windows > explorer. Is this possible? (I'm using bash and python scripts) I have a series of Cygwin Bash and Perl scripts for backing up my machines. I develop/debug them interactively using Cygwin Bash shells. Once everything works, I light them off using a shortcut pointing to a batch file that fires up Cygwin Bash and tells it to process the top-level Bash shell script: $ cat ssh-backup-all.bat C:\cygwin\bin\bash ./ssh-backup-all The top-level Bash shell script sets the environment up to match interactive login and then does it's job: $ cat ssh-backup-all #! /bin/sh . /etc/profile . /home/dpchrist/.bash_profile ##### do backup stuff HTH, David -- 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/ |
|
|
Re: How do I make scripts my PC executableDavid Christensen wrote:
> zip184 wrote: >> I have some scripts I'd like to run without starting cygwin and >> typing in their paths. Is there a way to make windows recognize that >> a file is a bash/python script and run them like as if I ran them in >> cygwin? I'd like to just be able to doubleclick them in windows >> explorer. Is this possible? (I'm using bash and python scripts) > > I have a series of Cygwin Bash and Perl scripts for backing up my machines. I > develop/debug them interactively using Cygwin Bash shells. Once everything > works, I light them off using a shortcut pointing to a batch file that fires up > Cygwin Bash and tells it to process the top-level Bash shell script: > > $ cat ssh-backup-all.bat > C:\cygwin\bin\bash ./ssh-backup-all > > > The top-level Bash shell script sets the environment up to match interactive > login and then does it's job: > > $ cat ssh-backup-all > #! /bin/sh > . /etc/profile > . /home/dpchrist/.bash_profile > ##### do backup stuff > the batch script read c:\cygwin\bin\bash -l ./ssh-backup-all regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- 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/ |
|
|
Re: How do I make scripts my PC executableGary Johnson wrote:
>> The first time you do that, windows will complain it doesn't know what to do >> with a sh file, and offer you the choice of looking up on the web or selecting >> from a list which program you want to open .sh files with; choose the >> select-from-a-list option, when the list appears click the browse button, find >> your way to cygwin\bin\bash.exe and select that. Make sure "Always use this >> program" is ticked, enter a nice descriptive name such as "Bash script" in the >> description box, OK it and away you go! > > That won't run the script in the same environment that it would get > when run from a Cygwin login shell, though, will it? I would think > the program might have to be a .bat file that contains something > like this (untested): > > C:\cygwin\bin\bash.exe --login -c %1 Last year I wrote app (weft) that allows you to double-click a .sh file in the Windows Explorer to start the script, a bit similar to the chere package. I basically does the registry settings mentioned above. Even tried to make it a package, but since nobody was interested in it I never continued. http://sourceware.org/ml/cygwin/2006-03/msg00311.html http://sourceware.org/ml/cygwin-apps/2006-10/msg00029.html If anyone is interested, I have put the archived of 0.4-1 back on-line. That version works reasonably well with local and mounted drives. It has problems with UNC paths. Regards, Frank -- 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/ |
|
|
RE: How do I make scripts my PC executableI wrote:
> $ cat ssh-backup-all.bat > C:\cygwin\bin\bash ./ssh-backup-all Steve Holden wrote: > Wouldn't it be possible to omit the first two executable lines and > have the batch script read > c:\cygwin\bin\bash -l ./ssh-backup-all I posted a sample shell session. The "$ cat ssh-backup-all.bat" is what I typed into my shell and the "C:\cygwin\bin\bash ./ssh-backup-all" is the result (e.g. the output of the "cat" command; the contents of "./ssh-backup-all"). HTH, David -- 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/ |
|
|
Re: How do I make scripts my PC executableDavid Christensen wrote:
> I wrote: >> $ cat ssh-backup-all.bat >> C:\cygwin\bin\bash ./ssh-backup-all > Steve Holden wrote: >> Wouldn't it be possible to omit the first two executable lines and >> have the batch script read >> c:\cygwin\bin\bash -l ./ssh-backup-all > I posted a sample shell session. The "$ cat ssh-backup-all.bat" is > what I typed into my shell and the "C:\cygwin\bin\bash > ./ssh-backup-all" is the result (e.g. the output of the "cat" command; > the contents of "./ssh-backup-all"). $ cat ssh-backup-all.bat C:\cygwin\bin\bash ./ssh-backup-all $ cat ssh-backup-all #! /bin/sh . /etc/profile . /home/dpchrist/.bash_profile ##### do backup stuff could be reduced to this: $ cat ssh-backup-all.bat C:\cygwin\bin\bash -l ./ssh-backup-all $ cat ssh-backup-all ##### do backup stuff -- Andrew DeFaria <http://defaria.com> Cannot find REALITY.SYS. Universe halted. -- 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/ |
|
|
Re: How do I make scripts my PC executableDavid Christensen wrote:
> I wrote: >> $ cat ssh-backup-all.bat >> C:\cygwin\bin\bash ./ssh-backup-all > > Steve Holden wrote: >> Wouldn't it be possible to omit the first two executable lines and >> have the batch script read >> c:\cygwin\bin\bash -l ./ssh-backup-all > > I posted a sample shell session. The "$ cat ssh-backup-all.bat" is what I typed > into my shell and the "C:\cygwin\bin\bash ./ssh-backup-all" is the result (e.g. > the output of the "cat" command; the contents of "./ssh-backup-all"). > you from putting two unnecessary lines in the shell script. Or so I thought. The -l (or --login) option has bash read its usual startup files, thereby avoiding the need four the course (".") commands at the beginning of the shell script. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- 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/ |
|
|
RE: How do I make scripts my PC executableAndrew DeFaria wrote:
> I think he was saying that this: > $ cat ssh-backup-all.bat > C:\cygwin\bin\bash ./ssh-backup-all > $ cat ssh-backup-all > #! /bin/sh > . /etc/profile > . /home/dpchrist/.bash_profile > ##### do backup stuff > could be reduced to this: > $ cat ssh-backup-all.bat > C:\cygwin\bin\bash -l ./ssh-backup-all > $ cat ssh-backup-all > ##### do backup stuff I forget the gory details, but I do remember that there was gore. I tried many permutations of Bash arguments, shell script commands, etc., and the above is what worked on my particular installation of Cygwin then (2006/09/14) and what still works on my particular installation of Cygwin today (last updated 2007-05-25). There may be other ways to get it to work; YMMV. David -- 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/ |
|
|
RE: How do I make scripts my PC executableSteve Holden wrote:
> I posted alternative content for the batch script that would save you > from putting two unnecessary lines in the shell script. Or so I > thought. > The -l (or --login) option has bash read its usual startup files, > thereby avoiding the need four the course (".") commands at the > beginning of the shell script. I tried the Bash --login option, and couldn't get *everything* to work (e.g. all the backup Bash and Perl scripts, and everything they depend upon) under all tested conditions -- invoking the shell script via Cygwin Bash, invoking the shell script via a batch file invoked from cmd.exe, invoking the batch file via Windows Explorer, invoking the batch file via a Windows shortcut, etc.. Please test your ideas, test my solution, figure out the obvious and unobvious differences, and post your results. David -- 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/ |
|
|
Re: How do I make scripts my PC executableDavid Christensen wrote:
> Steve Holden wrote: >> I posted alternative content for the batch script that would save you >> from putting two unnecessary lines in the shell script. Or so I >> thought. >> The -l (or --login) option has bash read its usual startup files, >> thereby avoiding the need four the course (".") commands at the >> beginning of the shell script. > > I tried the Bash --login option, and couldn't get *everything* to work (e.g. all > the backup Bash and Perl scripts, and everything they depend upon) under all > tested conditions -- invoking the shell script via Cygwin Bash, invoking the > shell script via a batch file invoked from cmd.exe, invoking the batch file via > Windows Explorer, invoking the batch file via a Windows shortcut, etc.. Please > test your ideas, test my solution, figure out the obvious and unobvious > differences, and post your results. > preferably with a following "because ..." would have been quite adequate. Now I have seen your reply to Andrew DeFaria I am somewhat better informed. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- 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/ |
|
|
RE: How do I make scripts my PC executableSteve Holden wrote:
> Well there's no need to be so defensive. A simple "that doesn't > work", preferably with a following "because ..." would have been > quite adequate. Now I have seen your reply to Andrew DeFaria I am > somewhat better informed. If my tone put you off, I apologize. Understand that GNU, Cygwin, Linux, *BSD, etc., are labors of love; users are expected to put effort into educating themselves, finding answers on their own, and helping others with difficulties. Requesting help on a support forum implies a willingness to learn, to do work, and to share the results. Understand that my solution is by no means the only or the best answer; I beat my head against the problem until I found something that worked, and then stopped there. If you follow my suggestion of "please test your ideas, test my solution, figure out the obvious and unobvious differences, and post your results", I suspect that we'll all have a better understanding of what's going on with Windows, Windows Explorer, cmd.exe, Cygwin, and/or Bash. David -- 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/ |
|
|
Re: How do I make scripts my PC executableDavid Christensen wrote:
> Steve Holden wrote: >> Well there's no need to be so defensive. A simple "that doesn't >> work", preferably with a following "because ..." would have been >> quite adequate. Now I have seen your reply to Andrew DeFaria I am >> somewhat better informed. > If my tone put you off, I apologize. Understand that GNU, Cygwin, > Linux, *BSD, etc., are labors of love; users are expected to put > effort into educating themselves, finding answers on their own, and > helping others with difficulties. Requesting help on a support forum > implies a willingness to learn, to do work, and to share the results. > Understand that my solution is by no means the only or the best > answer; I beat my head against the problem until I found something > that worked, and then stopped there. If you follow my suggestion of > "please test your ideas, test my solution, figure out the obvious and > unobvious differences, and post your results", I suspect that we'll > all have a better understanding of what's going on with Windows, > Windows Explorer, cmd.exe, Cygwin, and/or Bash. environments and the reluctance to learn more about them thus improving their environment and productivity. The -l option to bash *should* source /etc/profile and your ~/.bash_profile. Additionally it should source your .bashrc - if any of these are present. Additionally, if say run from cron, you'll have a non-interactive shell and the behavior should be slightly different. In any event it really is your responsibility to insure that your start up environment is configured correctly. Since you were obviously having difficulties there is still something wrong with *your* environment and as such I know that I, personally, would be concerned about that until I got it fixed. We cannot debug your environment because we don't have your environment. We don't have your /etc/profile (if you made any changes) and we don't have your ~/.bash_profile either. Additionally we don't have your perl and bash scripts that you've purposely left out of the equation here. Lastly we don't even have much of a description of what exactly goes wrong when you use -l instead of sourcing /etc/profile and ~/.bash_profile nor do we have any of the error messages. How then are we to post our results? Granted you may not care - you have a working solution and what the hell it's just two lines of code. However, as a profession I squint and say "That just ain't right" and "That's a kludgy fix" and it would bother me. I know from past experience that such things eventually have a knack of coming back and biting you in the ass later on... -- Andrew DeFaria <http://defaria.com> Sex: In America an obsession. In other parts of the world a fact. - Marlene Dietrich -- 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/ |
|
|
Re: How do I make scripts my PC executable-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 According to Andrew DeFaria on 8/30/2007 11:58 PM: > I'm always amazed how little people know about their own startup > environments and the reluctance to learn more about them thus improving > their environment and productivity. The -l option to bash *should* > source /etc/profile and your ~/.bash_profile. Additionally it should > source your .bashrc - if any of these are present. Actually, please reread 'man bash'. In a login shell, bash only directly sources /etc/profile, then the first of ~/.bash_profile, ~/.bash_login, or ~/.profile that exists. Therefore, if you want ~/.bashrc sourced in login shells, YOU must ensure that one of the other files sources it. - -- Don't work too hard, make some time for fun as well! Eric Blake ebb9@... volunteer cygwin bash maintainer -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG2AUP84KuGfSFAYARAodkAJ47Fk/5jL7bl1Dbf1e7UNVG5FnmMwCfeHU4 ODnZoHyH/weynFfhwFzwQy4= =s2mm -----END PGP SIGNATURE----- -- 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/ |
|
|
RE: How do I make scripts my PC executableOn 31 August 2007 13:10, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > According to Andrew DeFaria on 8/30/2007 11:58 PM: >> I'm always amazed how little people know about their own startup >> environments and the reluctance to learn more about them thus improving >> their environment and productivity. The -l option to bash *should* >> source /etc/profile and your ~/.bash_profile. Additionally it should >> source your .bashrc - if any of these are present. > > Actually, please reread 'man bash'. In a login shell, bash only directly > sources /etc/profile, then the first of ~/.bash_profile, ~/.bash_login, or > ~/.profile that exists. Therefore, if you want ~/.bashrc sourced in login > shells, YOU must ensure that one of the other files sources it. Well yeh, but in cygwin.... /artimi/software/firmware $ cat /etc/skel/.bash_profile # base-files version 3.7-1 # To pick up the latest recommended .bash_profile content, # look in /etc/defaults/etc/skel/.bash_profile # Modifying /etc/skel/.bash_profile directly will prevent # setup from updating it. # The copy in your home directory (~/.bash_profile) is yours, please # feel free to customise it to create a shell # environment to your liking. If you feel a change # would be benifitial to all, please feel free to send # a patch to the cygwin mailing list. # ~/.bash_profile: executed by bash for login shells. # source the system wide bashrc if it exists if [ -e /etc/bash.bashrc ] ; then source /etc/bash.bashrc fi # source the users bashrc if it exists if [ -e "${HOME}/.bashrc" ] ; then source "${HOME}/.bashrc" fi ... so it /should/ be the same thing anyway. cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/ |
|
|
RE: How do I make scripts my PC executableAndrew DeFaria wrote:
> ... Additionally, if say run from cron, Thanks for the reminder -- cron was another issue/ test case that drove me towards the solution I posted. > Since you were obviously having difficulties there is still something > wrong with *your* environment ... > and as such I know that I, personally, would be concerned about that > until I got it fixed. > However, as a profession I squint and say "That just ain't right" > and "That's a kludgy fix" and it would bother me. I know from past > experience that such things eventually have a knack of coming back > and biting you in the ass later on... I make no claim that my solution was "correct", "best", "ideal", "proper", "sexy", etc.; it just works AFAIC. Cygwin changes on a regular basis, causing breakage. So, I make, keep, and run images of Cygwin installations that seem to work, and only upgrade/update when I absolutely have to. I'm a Cygwin user, not a Cygwin developer; I have no desire to become the later (and this thread is reminding me why). If you feel compelled to research and explain the problems with the code I posted and provide a "better" answer, go for it. > We cannot debug your environment because we don't have your > environment. I didn't ask for help debugging my environment, TYVM. I was attempting to help zip184 with a problem I've faced in the past, and it turned into a huge exercise in negative reinforcement that will dissuade me from posting on this list again anytime soon. David -- 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/ |
|
|
Re: How do I make scripts my PC executableDavid Christensen wrote:
> Andrew DeFaria wrote: [...] >> We cannot debug your environment because we don't have your >> environment. > > I didn't ask for help debugging my environment, TYVM. I was attempting to help > zip184 with a problem I've faced in the past, and it turned into a huge exercise > in negative reinforcement that will dissuade me from posting on this list again > anytime soon. > Well that would be a shame, since you are obviously a helpful individual. Couldn't you just write this one time off to experience and give the list another chance? While I know of friendlier newsgroups than this there aren't many, and considering the volume of questions that people like Corinna and Dave get involved in I think they stay remarkably calm and courteous. For my part, if anything I said offended please accept my apologies. I just thought you misunderstood my original posting was all. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- 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/ |
| Free embeddable forum powered by Nabble | Forum Help |