Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shell (bash) command size limit in D3/Linux?

1 view
Skip to first unread message

Jonathan Rogers

unread,
Feb 4, 2003, 10:40:57 PM2/4/03
to
I'm having a problem with D3 Linux (v7.2.1 on RH 7.2). When I shell
out to Linux from within BASIC (at TCL would probably be the same),
eg:

EXECUTE "!mv /tmp/x.tif /backups"

...I seem to be limited to a total Unix command line length of ~2000
bytes or less. Since I can't find any reference or anyone else on the
Net complaining about this using bash itself, I assume it's another
brain-dead D3 limitation where they only pass down the first 2k of a
command to unix. (oops, sorry for the little editorialization there :)

Anywho, this is a problem because the API to an remote application I'm
working with does everything through a command line interface, and
I've got few other options to make it work. (Short of a kluge where I
check if the command line I'm about to execute is over 2k, and if it
is, write a small temporary script at the Unix level and then execute
it...ugly but it would probably work...)

Anyone else know for sure that this is a D3 problem? Any easy
workarounds known before I embark upon "plan B"? Major thanks in
advance.

/Dr. J/

Patrick Payne

unread,
Feb 5, 2003, 1:19:58 PM2/5/03
to
I don't remember the exact size limitation, but there is one. The
kludge you specify isn't so terrible. It is best to create a routine
(like execute.unix) and pass all your executes to that routine. One
nice thing about using a external script is you can more easily
control the output, modify the script (for excape characters), do
security checks, debug, etc.

Example
EXECUTE.UNIX(SCRIPT,OUTPUT,ERRORS)
SCRIPT.ID=@USER.NO:'.script'
OUTPUT.ID=@USER.NO:'.output'
ERROR.ID=@USER.NO:'.error'
OPEN 'unix:/tmp/scripts' TO SCRIPT.FILE ELSE
* Some Redhat systems have cleanup routines than clean out
* the tmp directory. This code will re-create the script
* directory if it is gone.
EXECUTE '!mkdir /tmp/scripts'
OPEN 'unix:/tmp/scripts' TO SCRIPT.FILE ELSE RETURN
END
DELETE SCRIPT.FILE, SCRIPT.ID
DELETE SCRIPT.FILE, OUTPUT.ID
DELETE SCRIPT.FILE, ERROR.ID
* here you can add special coding to deal with escape characters
* meaning, characters that unix does not like, like \ or $
WRITE SCRIPT ON SCRIPT.FILE, SCRIPT.ID
EXECUTE '!chmod a+x /tmp/scripts/':SCRIPT.ID:';
/tmp/scripts/':SCRIPT.ID:' > /tmp/scripts/':OUTPUT.ID:' 2>
/tmp/scripts/':ERROR.ID
READ OUTPUT FROM SCRIPT.FILE, OUTPUT.ID ELSE OUTPUT=''
READ ERRORS FROM SCRIPTS.FILE, ERROR.ID ELSE ERRORS=''
DELETE SCRIPT.FILE, SCRIPT.ID
DELETE SCRIPT.FILE, OUTPUT.ID
DELETE SCRIPT.FILE, ERROR.ID
RETURN

I have create a similiar routine for executing PERL and Expect
Scripts. Works like a charm!

thatsea...@hotmail.com (Jonathan Rogers) wrote in message news:<ba7d6941.0302...@posting.google.com>...

0 new messages