bash error - too many arguments - how to shorten?

Questions, suggestions, and answers for XnView on all Un*x platforms (Linux, HP-UX, AIX, ...)

Moderators: XnTriq, helmut, xnview

Post Reply
BabaG
Posts: 150
Joined: Sat Mar 03, 2007 6:41 am

bash error - too many arguments - how to shorten?

Post by BabaG »

i'm running the following in windows powershell without a problem (with
some differences, of course). when i run this i get an error that i have
too many arguments. how can i make this work?

Code: Select all

/usr/bin/nconvert -out tga -rtype lanczos -resize 2048 1365 -frestore -edetail -eedge 90 -rtype lanczos -resize 1024 682 -sharpen 25 -o /home/processing_01/Desktop/hdb1_internal_80gb/done_tga/%.tga /home/processing_01/Desktop/hdb1_internal_80gb/receiving/*
what i'm doing is resizing to a large size and performing some
enhancements. then i'm resizing downwards. the process seems to
retain more detail than just going in one step from the small size up
to the final size. in other words, i'm taking three steps, original--->
very large--->final rather than just two, original--->final.

one nice thing here is that i'm not making a temp file after the first
resize which would then have to be reopened for the second resize.
that saves time and, as i say, works under xp and powershell. is this
just too long for bash? or does the linux (using mandriva 2007.1)
version have a limitation that windows does not?

tried removing the repeated -rtype lanczos but that didn't shorten it
enough. thought it might be redundant anyway. wasn't sure it was
necessary to declare it again for the second resize. advice on that is
appreciated as well.

thanks,
BabaG
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: bash error - too many arguments - how to shorten?

Post by xnview »

BabaG wrote:i'm running the following in windows powershell without a problem (with
some differences, of course). when i run this i get an error that i have
too many arguments. how can i make this work?

/usr/bin/nconvert -out tga -rtype lanczos -resize 2048 1365 -frestore -edetail -eedge 90 -rtype lanczos -resize 1024 682 -sharpen 25 -o /home/processing_01/Desktop/hdb1_internal_80gb/done_tga/%.tga /home/processing_01/Desktop/hdb1_internal_80gb/receiving/*
You can use a text filelist
Pierre.
BabaG
Posts: 150
Joined: Sat Mar 03, 2007 6:41 am

Post by BabaG »

thanks pierre. this sounds good. unfortunately, i'm not sophisticated
enough to understand from your short tip how to make it work. what's
in the list, commands? filenames? how is it called?

could someone post a link to documentation on this? examples maybe?

also, i'm a little concerned that the issue is not the number of characters
in my command line but the number of commands being issued. using a
list will definitely cut down the amount of text by eliminating the long
paths but if the issue is that there are too many commands being issued
on a single line, how can i get around this? using a filelist will actually
add a command. does the linux version have (or any version) a limit on
the number of arguments that can be given in a single line?

and lastly, is my reuse of the -rtype lanczos a redundant declaration
or will declaring it once at the beginning apply to all resizes i do in my
command line?

thanks again,
BabaG
marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: bash error - too many arguments - how to shorten?

Post by marsh »

BabaG wrote:i'm running the following in windows powershell without a problem (with
some differences, of course). when i run this i get an error that i have
too many arguments. how can i make this work?
Your example works with Debian "Etch". Beyond experimenting with quotation marks or digging through some intense Unix documentation, I don't know what to suggest.
BabaG
Posts: 150
Joined: Sat Mar 03, 2007 6:41 am

Post by BabaG »

it was a bash thing. there's apparently a max argument for bash when
the kernel is compiled. that might account for the differences between
mandriva and debian. i got around it by creating a function to call
nconvert. here's a link to the site that i got that suggestion from:

http://www.linuxjournal.com/article/6060

and here's the script for anyone else who runs into a bash issue calling
nconvert:

Code: Select all

#!/bin/bash
 
cd /home/processing_01/Desktop/hdb1_internal_80gb
 
function nconvert_up-rez ()
	{
 
		while read line1; do
 
			/usr/bin/nconvert -quiet -out tga -rtype lanczos -resize 2048 1365 -frestore -edetail -eedge 90 -rtype lanczos -resize 1024 682 -sharpen 25 -o /home/processing_01/Desktop/hdb1_internal_80gb/done_tga/%.tga /home/processing_01/Desktop/hdb1_internal_80gb/receiving/$line1
 
		done
 
	}
 
ls -1 /home/processing_01/Desktop/hdb1_internal_80gb/receiving/ | nconvert_up-rez
Post Reply