Operating System - HP-UX
1829514 Members
1575 Online
109991 Solutions
New Discussion

ls command is interrupted

 
Consuelo Sierra
Occasional Contributor

ls command is interrupted

When I do "ls -la" from a remote HP workstation of a directory that have a lot of files, the command result is interrupted. Anyone knows if there are a configurable variable or parameter with the maximum number of files that can display the ls command?
konsu
8 REPLIES 8
Peter Kloetgen
Esteemed Contributor

Re: ls command is interrupted

Hi,

yes, you are right, the command line parameters of each command are limited to a specific number of characters. I think this is about 5500 characters alltogether for the command line. Simple solution:

create a script and do the listing with a for-construct:

for i in `ls -al $1`
do
ls -al $i
done

usage :
# script_name name_of_directory_to_list

Of course you can pipe this to a more-commmand.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
A. Clay Stephenson
Acclaimed Contributor

Re: ls command is interrupted

Hi:

I don't think there is an inherant limit to the number of files that ls can display BUT there is a limit to the size of the environment space/command line space that the exec() system call can use.

If you cd to the desired directory, then do your ls -la without any files specified, you should be fine.
If it ain't broke, I can fix that.
Peter Kloetgen
Esteemed Contributor

Re: ls command is interrupted

Hi Consuelo,

of course Clay is right... If you need these listings very open, the following script solves the problem also very easy

cd $1
ls -al
cd -

usage:

# script_name absolute_path_to_directory


Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Rodney Hills
Honored Contributor

Re: ls command is interrupted

If you get the following message-

sh: /usr/bin/ls: The parameter list is too long

Then the above solutions should work for you. If you are having a problem because you say you are listing a "remote" workstation, and are using "remsh" to execute the "ls" command, then it could be a different issue (like a networking issue).

-- Rod Hills
There be dragons...

Re: ls command is interrupted

Or it could be a dodgy file name on the remote host which contains the end-of-file character - this might cause remsh to close its socket before the rest of the data is pushed thro.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Steve Steel
Honored Contributor

Re: ls command is interrupted

Hi


I would not expect ls -la to have a problem with too much data because it uses no wild cards. You possibly have a network timeout if the link is slow.


Try
remsh node "cd dir;ls -la"|while read line
do
echo "$line"
done
Or
remsh node "cd $dir;ls -la > /tmp/$PPID;cat /tmp/$PPID;/bin/rm /tmp/$PPID"

See if they give breaks

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)

Re: ls command is interrupted

Does the following work?

remsh node "ls -la | cat -v"

If it does, it is definately bad characters in file names.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Olivier LEGRAND
Frequent Advisor

Re: ls command is interrupted

Hi,

I have the same problem when there is too much files in a directory. But I don't really know the standard limit. For this, I don't list the entire directory but just some part of this.
ls -al A*
ls -al B* ....


I am sure that there is some limit

Regards