shell or exec string length limit ?

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

shell or exec string length limit ?

Post by nedman47 »

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: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Post by dkl »

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

Post by nedman47 »

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: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Post by dkl »

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

Post by DOS386 »

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

Post by I Daniel »

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.
Post Reply