shell or exec string length limit ?

DOS specific questions.
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

shell or exec string length limit ?

Postby nedman47 » Oct 24, 2010 20:47

trying to run a command line email program called blat using shell or exec. it works with short test args but gives a return code of -1 if the arg string gets long enough to be useful.

Code: Select all

Shell "blat " & _
   " -body " & mfile & _
   " -to " & mto & _
   " -f " & mfrom & _
   " -subject " & msubject & _
   " -server " & mserver
dkl
Site Admin
Posts: 3211
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Oct 24, 2010 21:19

DOS limits command lines to about 128 characters, maybe you're getting close to that limit. It seems that blat supports a -@ command line option, so you can write your options to a file and then make blat read it in.
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Postby nedman47 » Oct 25, 2010 13:37

the -optionfile suggestion worked. thanks.

however i was hoping for a self-contained solution with no external files. the exact string that fails in freebasic works in a dos batch file, so i was thinking there might be additional length restrictions in freebasic that could be fixed.
dkl
Site Admin
Posts: 3211
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Oct 25, 2010 14:23

Weird, FB's shell() just passes the string to the DJGPP C runtime's system(), and if I understand the notes in the DJGPP faq correctly, it should work.
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Postby DOS386 » Nov 17, 2010 2:31

dkl wrote:Weird, FB's shell() just passes the string to the DJGPP C runtime's system(), and if I understand the notes in the DJGPP faq correctly, it should work.


The FAQ is not very good. The traditional place for commandline in DOS is the PSP and there are 128 Byte's left, but only 125 can be used reliably. For longer commandlines an environment variable can be created holding the full commandline, but there must be enough space free for it. I have no experience with very long commandlines, just brew 2 test programs passing a commandline, start with a length of 124 ;-)
I Daniel
Posts: 43
Joined: May 13, 2010 10:34
Location: Centurion, South Africa

Postby I Daniel » Dec 12, 2010 12:23

In DOS the length of COMMAND$ string is limited to 124 characters.

Looking at the given DJGPP faq link it would appear that EXECxx should be used instead of SHELL. The link explains how to use long command lines in more detail.

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 3 guests