- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Positional characters
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 01:10 PM
05-25-2001 01:10 PM
Is there a limit to how many positional characters I can have for a script? Where can I find that out? Can I increase it? I need to run a script that would have about 13000 positional characters!!!
Thanks,
Sanjay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 01:29 PM
05-25-2001 01:29 PM
Re: Positional characters
I can't tell exactly what you are trying to do.
If you are asking can the shell handle lines of 13000 character, then yes. Cut can also process lines that long. Awk cannot (I think the limit is about 3000 chars/lines depending upon implementation. If I were processing input records of that size, I think I would use
'gawk' from http://hpux.cs.utah.edu. Gnu's version of awk has options for specifying maximum input record size.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 01:40 PM
05-25-2001 01:40 PM
Re: Positional characters
Thanks for your reply. What I need to do is run a script like this:
scriptname 1 2 3 4 5 6 7 8 9 ... 13000 ...
When I try to run this I get an error message saying parameter list too long.
Unless there is a better way to do this? My positional characters are stored in a file. Is there a way to have my script read one line in the file, process and then loop back to the second line, process and so on until the EOF? That would or might work better?
Right now I am doing scriptname `cat filename` and I am getting the error.
Thanks,
Sanjay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 01:40 PM
05-25-2001 01:40 PM
Re: Positional characters
I think what you are looking at is handling 13000 characters in aline , then your answer is yes. Please go ahead and use it.
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 01:50 PM
05-25-2001 01:50 PM
Re: Positional characters
# getconf ARG_MAX
will return the maximum number of characters allowed in a argument list. Usually on 10.20 this is aboout 20,478. On 11.x this limit is 2,048,000. If you are are 10.x you can change the kernel parameter 'large_ncargs_enabled' to true to enable a similar limit as seen on 11.x. To do so requires patch PHKL_10177 on 800-series servers.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 02:05 PM
05-25-2001 02:05 PM
Re: Positional characters
The cat filename | while read -r line
seems to have worked. I am testing it now.
The ARG_MAX was also 20478 but I don't think I want to reconfigure my kernel for that!!! Good to know for the future.
Thanks,
Sanjay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 02:12 PM
05-25-2001 02:12 PM
Re: Positional characters
Ok I see the problem. First, be aware that aside from arg list too long errors, you can only directly address $1 through $9. You can then do a shift 9 and address the next 9 positional vars as $1 - $9.
You can make the shell read one line at a time. There are two basic techniques:
F=/tmp/myfile
cat ${F} | while read X
do
echo "${X}"
done
Sometimes this doesn't work well because you are executing with a pipe. Method 2 uses file descriptor reads and occurs in the foreground.
It's a little obscure but it's the weapon of choice.
F=/tmp/myfile
exec 9<$F
#avoid fdes 0,1,2 stdin,stdout,stderr - my
#convention is 9
X=`line <&9`
STAT=$?
while [ ${STAT} -eq 0 ]
do
echo "${X}"
X=`line <&9`
STAT=$?
done
Hope this helps, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 04:55 PM
05-25-2001 04:55 PM
Re: Positional characters
I cant understand why that abuse of piped cat:
cat file | while read line
do
xx
done
is similar to
while read line
do
x
done < file
but this syntax not use 2 process (with 3 standard open file) and 1 pipe to do exactly the same.
About of 13000 parameters... and cat:
think that sh must create a new process for `cat file` first, store in memory all data and then evaluate all parameters. It need lots of resources that can be avoided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2001 09:56 PM
05-25-2001 09:56 PM
Re: Positional characters
If you ever need to reference positional parameters beyond $9, I think you can use {},
e.g, ${10} , ${11} , etc.
Another useful command is 'shift' as Clay has mentioned.
Enjoy the scripting. Regards,
Mladen