-
-
Save damc-dev/eb5e1aef001eef78c0f4 to your computer and use it in GitHub Desktop.
cmd /c ""C:\Program Files (x86)\Git\bin\bash.exe" --login -i -- H:\Daily_Reports\yesterdayTogglReport.sh" |
Thanks, sir! You saved me a LOT of time :)
Thanks!
How to run git bash With Administrator? :)
I don't even understand how that last part works, -- path/to/file/script.sh but i searched far and wide for a solution and this was the only thing that worked. Thanks a bunch for sharing this!
I was about to lose my nerves while searching how to do this. Thank you! Works like a charm :-)
Thanks
I know this is just a gist and not detailed how-to tutorial, but...
- My git version must be x64, as I didn't need to specify
(x86)
in the path - what's the advantage of doing the
cmd /c
vs direct invocation? In other words, why not just"C:\Program Files (x86)\Git\bin\bash.exe" --login -i -- H:\Daily_Reports\yesterdayTogglReport.sh
? - is there a difference between Git\bin\bash.exe and Git\bin-bash.exe ?
- I'm not quite sure why it didn't work when I attempted to run a script with parameters, as otherwise written. It seems I needed to drop
--
in favor of-c
and add single-quotes around my within-bash command. In other words,"C:\Program Files\Git\bin\bash.exe" -i -c '/usr/bin/awk -F , -f process.awk *.txt'
worked if I specify a "start in" directory, whereas"C:\Program Files\Git\bin\bash.exe" --login -i -- '/usr/bin/awk -F , -f process.awk *.txt'
didn't (with or without the single quotes). Any comments on what the most universal method is? - Is there a way to get it to either run minimized or hidden, rather than opening a window in the middle of my desktop (maybe this is where the
cmd /c
comes in)? Alternatively, if I wanted to leave the window open after execution (to read the output), could I do that? Can I have it leave the window open upon error but close out if no error?
Thanks!
Hi David,
I have a bash script which copies the files from Windows 2016 Server (Source) to Linux SFTP server (Destination), both are in different network and VPN has been established and files are getting copied.
I tried the running the bash script using bat file in cmd prompt, but it was idle for quite long time without any response.
C:\Users\Administrator>stagescript.bat
C:\Users\Administrator>cmd /c ""C:\Program Files\Git\bin\bash.exe" --login -i -- C:\Users\Administrator\Documents\scripts\stage.sh"
Terminate batch job (Y/N)?
Kindly let me know what am I missing?
Note: It was working fine with other simple bash scripts but not the one which I am using.
this below works to execute a ruby script from git bash via scheduled task
note:
- the windows-style pathing for the git bash portion
- the *nix-style pathing after
-C
(to declare the working directory for the script - important for gems installed there with bundler) - the space between the linux-style script base directory path and the name of the script itself
- ruby.exe must be on the PATH
"C:\Program Files\Git\bin\bash.exe" --login -c "ruby -C /x/repos/scripts script.rb"
This was a big help for me as well. I made a slight change to the syntax though.
cmd /c '"C:\Program Files\Git\bin\bash.exe" --login -i -- H:\Daily_Reports\yesterdayTogglReport.sh'
Using single quotes ( apostrophes ) to enclose everything that is being passed to cmd /c .
Thanks again.
Thanks
In windows 10 task scheduler action configuration this can also be done by
Action: Start a program
Program/script: "C:\Program Files\Git\bin\bash.exe"
(or whatever your bash.exe location is)
Add Arguments: --login -i -- H:\Daily_Reports\yesterdayTogglReport.sh
Thanks!!!!! :D
Big help !
Unfortunately, opening bash.exe always ask me for ssh key passphrase (work requirement).
Is there a way to avoid those passphrases ?
Thanks !
There are a number of options.
I just duplicated my key and removed the passphrase for batch jobs (insecure depending on where/how you store your key files, but solves this particular problem). This may violate your company's requirement, so don't do this when you've been required to have a passphrase; use this second option.
Another option is in this: https://stackoverflow.com/questions/21095054/ssh-key-still-asking-for-password-and-passphrase (You're looking for the ssh-add/ssh-agent info). Also look here: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases
In windows 10 task scheduler action configuration this can also be done by
Action: Start a program Program/script:
"C:\Program Files\Git\bin\bash.exe"
(or whatever your bash.exe location is) Add Arguments:--login -i -- H:\Daily_Reports\yesterdayTogglReport.sh
Hi tried, but the action result stucked 'in esecution'
I tried via CMD and It works properly.
Any suggestion?
Same problem here. Did you discover a solution?
@ryansherby I bypass the cmd and call it the .sh file directly instead.
It worked I had a problem and in Start In I had to puth the path of the .sh file
Thank you a lot
thank you!
Cheers bro, I was able to run my sh scripts with your reference :)