Increase command length for ksh shell on Redhat Linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Increase command length for ksh shell on Redhat Linux
# 1  
Old 10-15-2019
Increase command length for ksh shell on Redhat Linux

I have a ksh shell script and i need to pass arguments which are generated by data pulled from a database.

When the argument to the shell script is too long (about 4000 charecters) the below is the issue observed.

I copy the command which is 4000 charecters long from the logs and paste it for the ksh shell on my RedHat linux; then only part of the command (not the complete copied command text) gets pasted

Can you please help increase / tweak some settings so I can simply copy paste and execute the shell script irrespective of the command length or atleast increase it to a substantial length?

Below are the details:

Code:
# getconf LINE_MAX
2048
# getconf ARG_MAX
51200000
# getconf _POSIX_ARG_MAX 
51200000

Linux mymac 3.10.0-957.12.1.el7.x86_64 #1 SMP Wed Mar 20 11:34:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

However, I did not find any of the above variable in /usr/include/limits.h file.

I'm not sure what value I should change and in which file ?

Note: the issue of not being able to paste the entire command only happens with ksh shell. The problem is not seen with bash shell.

Can you please suggest ?
# 2  
Old 10-15-2019
It's a hardcoded limit, not something trivially changed. Even if you coerce getconf into changing, it won't be reflected in programs. But I suspect you're using a crusty old pdksh/ksh88, newer ksh is quite willing to accept enormous arguments on Linux.

Code:
$ # create 5 kilobyte file
$ for ((X=0; X<5000; X++)) ; do printf "0" ; done > 5k
$ cat arg.ksh

#!/bin/ksh

echo "$1"

$ xargs ksh arg.ksh < 5k | wc -c

5001

$ ksh --version

  version         sh (AT&T Research) 93u+ 2012-02-29

$

# 3  
Old 10-15-2019
xargs is cheating: it runs the ksh with max_args then again with the remaining args...
A correct test is
Code:
ksh arg.ksh $(cat 5k) | wc

# 4  
Old 10-15-2019
Looks like i was not able to understand as well as explain the problem.

here is the problem where i'm running the test.sh script and passing a very long argument with terminal set to ksh like below.

command i wish to run:
Code:
./test.sh argone argtwo argthree ..... very lengthy string .... argtwohundredfour argtwohundredfive argtwohundredsix argtwohundredseven argtwohundredeight

when i copy the above and paste it in my ksh terminal it does not paste the entire copied text but only till say "argtwohundredfour" as below.

Code:
./test.sh argone argtwo argthree ..... very lengthy string .... argtwohundredfour

I then have to copy the remaining args and add to the previous manually. entire thing does not get copied in one go in ksh like it does in bash.

That is the problem. If there is a solution to this I will be excited to know.
# 5  
Old 10-15-2019
Maybe you hit the LINE_MAX=2048?
This should be the buffer for a physical line (usually an input line).
Try to construct a longer virtual line by inserting a \ at the very end of the physical line, and continue on the next physical line.
For example
Code:
./test.sh argone \
argtwo \
argthree \
...

# 6  
Old 10-15-2019
Quote:
Originally Posted by MadeInGermany
Maybe you hit the LINE_MAX=2048?
This should be the buffer for a physical line (usually an input line).
Try to construct a longer virtual line by inserting a \ at the very end of the physical line, and continue on the next physical line.
For example
Code:
./test.sh argone \
argtwo \
argthree \
...

Any other solution please ? As the arguments are constructed by variable substituted values constructed at runtime.

Considering I have root privileges , can I modify this setting somewhere ?

Last edited by mohtashims; 10-15-2019 at 05:57 PM..
# 7  
Old 10-15-2019
Quote:
Originally Posted by MadeInGermany
xargs is cheating: it runs the ksh with max_args then again with the remaining args...
I've verified that it's not cheating in my case by having the script print an extra character. The count would be out several more if ksh were being run repeatedly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is there a maximum length for a shell script command?

Is there a maximum length for a shell script command? How can I detect that in my OS? For example, if I have something like: command A | command B | command C | awk '{print $1 $2 $3 $4 $5}' then can we break the commands and also the arguments inside awk ? Thanks (11 Replies)
Discussion started by: hbar
11 Replies

2. UNIX for Advanced & Expert Users

How to increase max username length?

Hi, This is my first post to this site. So kindly forgive if I am writing in a wrong section. My query is that... I want to modify the max username length size. I guess it is 32/64 on CentOS. Now I want to change it to 128. Is there any way to do that? Thanks in advance!! :) (4 Replies)
Discussion started by: ajay303
4 Replies

3. Shell Programming and Scripting

New line character problem with ksh on Redhat Linux

Guys, I would like to discuss the problem I am seeing with echo “\n” statement in Redhat Linux Enterprise 5.3 version. I have a shell script that was written couple of years back for generic UNIX platforms based on ksh and was tested on Solaris 8,9,10 ; AIX 5.3 and Red Hat Enterprise Linux... (5 Replies)
Discussion started by: rijeshpp
5 Replies

4. Shell Programming and Scripting

Maximum command length in bourne shell

Hi, I wanted to know what is the maximum length of command which can be run on a bourne (sh) shell? Where can I find that information? Is it different for different OS flavors? Please help. Thanks, Vineet (10 Replies)
Discussion started by: vineetd
10 Replies

5. Red Hat

Increase Password length

Hello All, I am using RHEL 4. Currently maximum password length limit is set to 8 on my system. Please tell what do i need to change to increase this limit to say 20. I changed the login.defs and included the following line - " PASS_MAX_LEN 20 " but this dint work. I further... (7 Replies)
Discussion started by: shamik
7 Replies

6. UNIX for Dummies Questions & Answers

How to increase the maximum record length

Hi, I need to create a file of record length more than 300 characters. But in my unix box, i am able to create a file only with a maximum of 256 characters per record. Is there anyway i can create a file with more than 300 characters in this case? Or How to increase the maximum record... (1 Reply)
Discussion started by: mahish20
1 Replies

7. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

8. UNIX for Dummies Questions & Answers

Redhat linux command to check Version

Hi All, I need to know RedHat linux version installed on a different servers. I know uname -a or /proc/version Is any other command to know the Linux version???? When we telnet to any of the Linux server, the version shows very clearly like Red Hat Enterprise Linux ES release 3 (Taroon... (1 Reply)
Discussion started by: bache_gowda
1 Replies

9. UNIX for Dummies Questions & Answers

Maximum Command Length for Korn shell

What is the maximum size of a command which can be given in telnet command prompt in unixfor Korn shell? (2 Replies)
Discussion started by: miltony
2 Replies

10. UNIX for Advanced & Expert Users

MYSQL command to take a backup of the database in Redhat linux 7.2

I am new to mysql database , we have a mysql database running on linux , and we use mysql database for bugzilla, so we wanted to take a backup . what is the command for taking the entire database backup from the command prompt with all options. Thanks in advance Bache Gowda (4 Replies)
Discussion started by: bache_gowda
4 Replies
Login or Register to Ask a Question