|
-
Dec 14th, 2022, 09:48 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Using Git Bash from a form
Hi
I've been using some Git Bash in a very basic way to split up text files like this:
Code:
split myfile.txt -l 10000 --additional-suffix=.csv
I thought it would be useful to get this functionality in a vb.net program. I've used a steamreader in the past do this sort of thing, but Git Bash is so quick I thought I would create a simple windows form app to allow the user to input the file name and split size, then run git-bash.exe as a process with the variables.
Could anyone tell me how to do this? - I don't know how to go about passing the variables to Git Bash.
Thanks!
-
Dec 14th, 2022, 10:00 AM
#2
Re: Using Git Bash from a form
You can use a process to run an exe with variables-arguments:
https://learn.microsoft.com/en-us/do...s?view=net-7.0
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 14th, 2022, 10:01 AM
#3
Re: Using Git Bash from a form
Lookup Process.Start ... you can pass it parameters that include the path and name of hte process to start, and parameters to pass to that process.
-tg
-
Dec 14th, 2022, 10:10 AM
#4
Thread Starter
Addicted Member
Re: Using Git Bash from a form
Hi
Thanks for quick replies - I've done a process with parameters before, but I don't know how to pass a command to the bash?
I suppose what I'm really asking here is how to launch git bash from a cmd window with the 'split' instruction I want to use - instead of launching the bash and then entering the commands there.
If I can do that, I can use a process in vb.
Sorry, I guess this isn't really a vb question after all!
-
Dec 14th, 2022, 10:28 AM
#5
Re: Using Git Bash from a form
What do you mean commands?
startInfo.Arguments will pass the -argument. What is a command?
https://learn.microsoft.com/en-us/do...s?view=net-7.0
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Dec 14th, 2022, 10:40 AM
#6
Thread Starter
Addicted Member
Re: Using Git Bash from a form
Hi
I think I found the answer.
I can do this from cmd window by putting this line:
Code:
split myfile.txt -l 10000 --additional-suffix=.csv
into a new text file called 'script' and giving it a .sh suffix
I can then run from command line with:
Code:
C:\Program Files\Git\git-bash.exe script.sh
This works from a DOS window, so I should be able to run it from vb.net as a process
Cheers
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|