Results 1 to 6 of 6

Thread: [RESOLVED] Using Git Bash from a form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2018
    Posts
    160

    Resolved [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!

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2018
    Posts
    160

    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!

  5. #5
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2018
    Posts
    160

    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
  •  



Click Here to Expand Forum to Full Width