The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Lines too long error thana UNIX for Dummies Questions & Answers 2 05-09-2008 10:12 AM
word too long..problem while sourcing .cshrc mobydick UNIX for Dummies Questions & Answers 1 05-08-2008 10:11 PM
word too long panchpan SUN Solaris 7 02-04-2008 04:34 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 07:29 AM
arguments too long error kburrows Shell Programming and Scripting 0 07-21-2006 12:35 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-21-2009
nixjennings nixjennings is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 8
word too long error in script but not elsewhere...

Hi,

I have written a tcsh script that reads 3 directories, lists the files within them and continues on to evaluate each file independently. When I run the script, it gets to a certain directory that contains ~250 files, when you echo the directory, there are 4332 characters. So, when I use the echo command to list the files within that directory within the shell script, it produces a "word too long" error. The confusing thing is that when I run the commands directly in the shell (i.e., not through a script, type each command separately), I don't get the error. Is there anyone out there that can help me understand why the script fails, but running the commands directly in the shell does not result in an error?

Here is the list of the directories:
drwxr-sr-x 2 4096 Jan 21 10:37 SRS00001
drwxr-sr-x 2 4096 Jan 20 18:27 SRS00008
drwxr-sr-x 2 4096 Jan 21 11:04 SRS00009

Here is the section of the script (and output) that is failing:

set dlist = ();
set flist = ( `ls -d *` )
foreach f ($flist)
if ( -d $f ) set dlist = ( $dlist $f )
echo "dlist = $dlist"
------------------------------------------------------
output of the echo command for each iteration:
dlist = SRS00001
dlist = SRS00001 SRS00008
dlist = SRS00001 SRS00008 SRS00009

------------------------------------------------------
end

foreach d ( $dlist )
set flist = ( `find $d -name "*"` )
echo $flist
------------------------------------------------------
output of the echo command for each iteration:
SRS00001 SRS00001/IMG00000 SRS00001/IMG00001 ... SRS00001/IMG00049
SRS00008 SRS00008/IMG00000 SRS00008/IMG00001 ... SRS00008/IMG00024
SRS00009 SRS00009/IMG00000 SRS00009/IMG00001 ... SRS00009/IMG00247

------------------------------------------------------
end

As you can see, the last directory contains 248 images, resulting in an echo output of more than 4000 characters. I assume this is why I get the "word too long" error when I run the script, but why does it work when I manually type in the command in the shell?

I've been struggling with this for 2 days, and the script won't continue once it hits this directory, so I can't move on from this point. If anyone can help, it would be greatly appreciated. Thank you in advance!

nix
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0