From owner-freebsd-amd64@FreeBSD.ORG Thu Jun 30 10:06:42 2005 Return-Path: X-Original-To: freebsd-amd64@FreeBSD.ORG Delivered-To: freebsd-amd64@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0707016A41C; Thu, 30 Jun 2005 10:06:42 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57CEC43D58; Thu, 30 Jun 2005 10:06:41 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (wtcfqp@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.1/8.13.1) with ESMTP id j5UA6auq017309; Thu, 30 Jun 2005 12:06:36 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.1/8.13.1/Submit) id j5UA6ZV9017308; Thu, 30 Jun 2005 12:06:35 +0200 (CEST) (envelope-from olli) Date: Thu, 30 Jun 2005 12:06:35 +0200 (CEST) Message-Id: <200506301006.j5UA6ZV9017308@lurza.secnetix.de> From: Oliver Fromme To: freebsd-amd64@FreeBSD.ORG, obrien@FreeBSD.ORG In-Reply-To: <20050629221047.GC20836@dragon.NUXI.org> X-Newsgroups: list.freebsd-amd64 User-Agent: tin/1.5.4-20000523 ("1959") (UNIX) (FreeBSD/4.11-RELEASE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Cc: Subject: Re: sript (Perl) test code needed X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-amd64@FreeBSD.ORG, obrien@FreeBSD.ORG List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2005 10:06:42 -0000 David O'Brien wrote: > I know this should be trivial to do in perl and maybe someone here has the > time to hack it up. I want a small test script (actually some other > scripting language than perl preferred). > > The script should run the following commands until an error is returned: > > ls > ls . > ls ./ > ls ./. > ls ././ > ls ././. > ls ./././ > etc... > > and when the error occurs print out the length of the command line. > I want to get the bottom of the "command too long" issue that causes too > much trouble deploying Java on FreeBSD/AMD64. This is pretty easy to do in plain /bin/sh. CMD="ls " while $CMD >/dev/null; do case "$CMD" in *.) CMD="$CMD/";; *) CMD="$CMD.";; esac done echo "length == ${#CMD}" On my old 4-stable/i386 machine, it reports "File name too long" when the length of the command reaches 1027 chars (i.e. the path is 1024 chars, which is PATH_MAX). When replacing "/" with " ", so that the commands become "ls . . . . " etc., it runs a lot longer, until finally it reports "argument list too long" when the command length reaches 61344 chars. Since my environment is 2079 chars, and the " >/dev/null" is another 12 bytes, that adds up to 65532 bytes. ARG_MAX is 65536. Don't ask me where the remaining 4 chars go. Maybe some safety margins in the implementation, or alignment issues. Best regards Oliver PS: I couldn't help writing the same in Python, too. :-) It reports the same result, of course. import os cmd = "ls " while os.system(cmd + " >/dev/null") == 0: cmd = cmd + "/."[len(cmd) % 2] print "length ==", len(cmd) And in awk ... BEGIN { cmd = "ls " while (system(cmd " >/dev/null") == 0) cmd = cmd substr("/.", length(cmd) % 2 + 1, 1) print "length ==", length(cmd) } -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. (On the statement print "42 monkeys" + "1 snake":) By the way, both perl and Python get this wrong. Perl gives 43 and Python gives "42 monkeys1 snake", when the answer is clearly "41 monkeys and 1 fat snake". -- Jim Fulton