Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to fix :[too many arguments error in code Post 302196522 by Brewer27 on Sunday 18th of May 2008 08:17:54 PM
Old 05-18-2008
How to fix :[too many arguments error in code

I am getting a :[ too many arguments error on line 28 if I do not specify a directory or file when running my code. Any suggestions as I am stuck here.

if [ $# -gt 1 ]; then
echo "Enter zero or one file"
echo "You must use a valid directory"
echo "Current directory is:" pwd
exit 0
fi
#Flag Variable
flag=1
#Code for no arguments
if [ $# -eq 0 ]; then
for filename in *
do
if [ -f $filename ]; then
linetest1='wc -l < $filename'
# Execution
if [ $flag -eq 1 ]; then
startline=$linetest1
startfile=$filename
flag=2
fi

#End Code Execution
if [ $startline -lt $linetest1 ]; then
startline=$linetest1
startfile=$filename
fi
fi
done
echo "File $startfile has the maximum number lines ($startline)."
exit 0
fi

#If only one Variable
if [ $# -eq 1 ]; then
cd $1
for filename in *
do
if [ -f $filename ]; then
linetest1='wc -l < $filename'
if [ $flag -eq 1 ]; then
startline=$linetest1
startfile=$filename
flag=2
fi
if [ $startline -lt $linetest1 ]; then
startline=$linetest1
startfile=$filename
fi
fi
done
echo "File $startfile has the maximum number lines ($startline)."
exit 0
fi



Thanks.
 

3 More Discussions You Might Find Interesting

1. Programming

why ORA-00600: internal error code, arguments: [17059]?

I have code to update some records in MyTable1 in sql which I am calling from ksh file (unix script). I am getting below error - MyTable1 TABLE UPDATE FAILED : UPDATE MyTable1 SET ph_nr = '+44 (0)20 8960 1233' , update_dts = sysdate WHERE ID = 499037 ORA-00600: internal error code,... (2 Replies)
Discussion started by: rshivarkar
2 Replies

2. Shell Programming and Scripting

How to fix my code in Perl?

Hi Perl users, Could you help me how to fix my code so I can get the expected output as seen below? is there missing in my program? Thank You #!/usr/bin/perl -w use strict; open (FH, "< file1.log") or die $!; open (FL, "< file2.log") or die $!; my $file = "result.log"; my... (1 Reply)
Discussion started by: askari
1 Replies

3. Shell Programming and Scripting

Help me please to fix my error

Can you help me to fix my error please?! I checked the code and I think there is no mistake, but when I run it gives me error such line 1: /Users/Manu/trials/hosts: is a directory sort: open failed: /Users/Manu/trials/hosts/*: No such file or directory Help me please... mycode NAME value.... (9 Replies)
Discussion started by: Manu1234567
9 Replies
FBSQL_ERRNO(3)								 1							    FBSQL_ERRNO(3)

fbsql_errno - Returns the error number from previous operation

SYNOPSIS
int fbsql_errno ([resource $link_identifier]) DESCRIPTION
Returns the numerical value of the error message from previous FrontBase operation. Errors coming back from the fbsql database backend don't issue warnings. Instead, use fbsql_errno(3) to retrieve the error code. Note that this function only returns the error code from the most recently executed fbsql function (not including fbsql_error(3) and fbsql_errno(3)), so if you want to use it, make sure you check the value before calling another fbsql function. PARAMETERS
o $ link_identifier -A FrontBase link identifier returned by fbsql_connect(3) or fbsql_pconnect(3).If optional and not specified, the function will try to find an open link to the FrontBase server and if no such link is found it will try to create one as if fbsql_connect(3) was called with no arguments. RETURN VALUES
Returns the error number from the last fbsql function, or 0 (zero) if no error occurred. EXAMPLES
Example #1 fbsql_errno(3) Example <?php fbsql_connect("marliesle"); echo fbsql_errno() . ": " . fbsql_error() . "<br />"; fbsql_select_db("nonexistentdb"); echo fbsql_errno() . ": " . fbsql_error() . "<br />"; $conn = fbsql_query("SELECT * FROM nonexistenttable;"); echo fbsql_errno() . ": " . fbsql_error() . "<br />"; ?> SEE ALSO
fbsql_error(3), fbsql_warnings(3). PHP Documentation Group FBSQL_ERRNO(3)
All times are GMT -4. The time now is 07:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy