Announcement

Collapse
No announcement yet.

SHELL command line problem

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

  • SHELL command line problem

    I have a long command line which will work fine from the command prompt but when I try to use it with the SHELL statement it fails. I think the problem is that the command line is being truncated.

    Are the limits to the SHELL command line length? Are there any work arounds when a longer command line is needed?

    The command line statement I am using is:

    Code:
    7zg.exe a -tzip -r C:\PBWin90\FireFly30\Samples\Archiver\release\Archiver.zip C:\PBWin90\FireFly30\Samples\Archiver\*.*
    This works fine at the CMD Prompt

    But the equivalent SHELL statement does not:
    Code:
    SHELL "7zg.exe a -tzip -r C:\PBWin90\FireFly30\Samples\Archiver\release\Archiver.zip C:\PBWin90\FireFly30\Samples\Archiver\*.*"
    Any suggestions?

  • #2
    Marty --

    Is 7zg.exe in your PATH?

    What does ERR tell you?

    Try creating a batch file containing the long line, and SHELL to the batch.

    -- Eric
    "Not my circus, not my monkeys."

    Comment


    • #3
      To answer your question, yes there is a limit, but I think it's something like 1500 characters so you aren't even close.

      However, when you have multiple command options like this, it sometimes helps to call the command processor explicitly...
      Code:
      SHELL "Cmd /c tg7Zip.exe yadda yadda yadda"
      Or, you could replace SHELL with something which explicitly lets you separate "the command" from "the options" , eg, Win 32: Monitor Process with ShellExecuteEx June 22, 2001

      But start with what Eric suggested... using the provided tools ("ERR" is a tool) to determine what is really wrong. After all, you wouldn't want to amputate your leg if the problem is actually in your arm, would you?

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

      Comment


      • #4
        Thanks for the suggestions. I will try to pin done the problem more exactly. And give both suggestions a try. I was thinking about trying ShellExecute .

        Is there a limit to the length of a command line ? I was thinking it is 256 characters?

        Comment


        • #5
          Is there a limit to the length of a command line ? I was thinking it is 256 characters?
          As I said above, from SHELL I am pretty sure there is a limit but it's some big number. Hmm, if there is a limit, it might be, it could be, it should be... in the PB help file. Let's look....nope, no indication there. I guess that means "unlimited." (well, I guess it could mean "Oops, we forgot to include that in the help file.").

          As far as a limit from the command prompt... that I don't know.

          But I rarely use SHELL from a program, and I can't imagine typing a command-line that long from a "C:" prompt.... anything that long I just write a CMD file and run that.

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

          Comment


          • #6
            Somewhere in the past, I could swear at some point both shell and commandline were limited to 255 chars

            as things progressed without my researching...the chars became folder structures with an 8.3 format, and then expanded again with the operating system.

            So interesting test...even though your path appears smaller than the so said limits....does it work if made into a 8.3 format???



            Could be a problem of Long file names vs Short File Names that most of us have seen
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              >Could be a problem of Long file names vs Short File Names that most of us have seen

              The length is not usually the problem in these cases.... it's spaces in the file name.

              See WinApi function PathQuoteSpaces(), but you can probably write your own function to do this faster than you can find the doc for this.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Code:
                7zg.exe a -tzip -r C:\PBWin90\FireFly30\Samples\Archiver\release\Archiver.zip C:\PBWin90\FireFly30\Samples\Archiver\*.*
                This works fine at the CMD Prompt

                But the equivalent SHELL statement does not:
                Code:
                SHELL "7zg.exe a -tzip -r C:\PBWin90\FireFly30\Samples\Archiver\release\Archiver.zip C:\PBWin90\FireFly30\Samples\Archiver\*.*"
                Not sure if these will help, but I'd try:

                1. Are you sure the commandline is getting truncated? You might want to write a dummy application that you can SHELL to, that will show you the commandline it receives.

                2. One commandline you didn't show:

                SHELL 7zg.exe a -tzip -r "C:\PBWin90\FireFly30\Samples\Archiver\release\Archiver.zip C:\PBWin90\FireFly30\Samples\Archiver\*.*"

                Surround with CHR$(34) as needed by the SHELL statement...

                -John
                Last edited by John Montenigro; 7 Jan 2009, 03:36 PM.

                Comment


                • #9
                  my understanding is that the limit of the command line length is as follows:

                  windows 95 - %MAX_PATH is the limit
                  NT-based o/s's (NT, 2000, 2003, xp, vista) - the technical limit it 32767 (for createprocess) or 2048 for shellexecute(Ex)

                  to test it, i'd just shell to a batch file and echo back what you're sending. then you can be sure about what's happening.

                  -don
                  Don Dickinson
                  www.greatwebdivide.com

                  Comment

                  Working...
                  X