Announcement

Collapse
No announcement yet.

Stdin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stdin

    I'm trying to create a .bat file dynamically using PBCC and then shell out of the program to execute it. The .bat file contains a program to backup a database but asks for the password. I can't find a way to enter the password other then by typing it in.

    Any suggestions how I may automate entering the password?

    Thanks !

    John

  • #2
    You can pass "commandtails" to a batchfile. It's been years since I messed with that stuff, so this'll most likely need some corrections by others:

    An example of using "commandtails in a .BAT file:

    if %1. == . then

    The "%1" would be replaced by the command processor with the first space-delimited argument in the commandtail. "%2" would be replaced by the second one, etc. I *believe* you can pass up to 8 arguments to a batch file.

    But please only use this a reference for your own research, as my memory of it is very archane.

    Comment


    • #3
      Hi,

      the first question is, does the backup program accept the password as a parameter ?

      If yes, build the line like that

      "...\MyBackup.exe ... "+cPassWord$

      if not, maybe the redirectors can help:

      MyBackup.exe < pw

      or

      pw | MyBackup.exe

      in any case you have to test this in a command window directly. If this works, you can build a CMD file with the same syntax. If your backupsoftware will not accept the pw as a parameter, you can try to send keystrokes from one program to another, but I don't know how to do that.
      Regards,
      Hubert

      ------------------------------------
      http://familie-brandel.de/index_e.html

      Comment


      • #4
        Not that it deals with the password problem, but why bother with a batch file at all?

        There is no functional difference between ...
        Code:
        FUNCTION PbMain...
        
            Build and save batchfilecommands to BatchFileName
            SHELL CMD.EXE & BatchFIleName
        END FUNCTION
        ...and....
        Code:
        FUNCTION PbMain
        
           Build   FirstBatchFileCommand
           SHELL FirstBatchFileCommand
        
           Build   SecondBatchFileCommand
           SHELL SecondBatchFileCommand
          ..... 
        
        END FUNCTION
        Just a thought ....

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          I think Clay is on the right track. The backup program is asking for the password directly and doesn't accept redirection as a substitute for keyboard entry.

          I know this is a bit off topic for the PBCC forum but I appreciate the help !

          John

          Comment


          • #6
            Oh, well, as long as y'all have your hearts set on using *.bat or *.cmd files, you may as well read up on them:


            Starting the command shell



            Command-line reference A-Z:


            Command-line Parameters
            See "for" in A-Z reference.

            I-O Redirection from command line:


            From any of the above links, lots of other links to click on.

            But it's still putting an extra level of complexity into your application to use bat/cmd files from a program you are writing. There's nothing you can do from a bat/cmd file you can't do directly from your program, and nine times out of ten you don't need SHELL (or equal) for anything except running another executable program.

            eg this recent thread:


            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment

            Working...
            X