Josh Clark
Josh Clark

Reputation: 655

Command Line limit for Solaris

I have an app that executes commands on a Linux server via SSH just fine. When I connect to a Solaris server, things don't work. It seems that the Solaris command line is limited to 267 characters.

Is there a way to change this?

Update: As was pointed out before, this is a limit to the default shell for Solaris (sh) vs Linux (bash). So, now the question is, is there a way to change the limit for sh?

Upvotes: 1

Views: 12080

Answers (5)

pituś
pituś

Reputation: 11

Simply change shell interpreter for user (edit /etc/passwd) or temporary run another shell for eg. korn shell as below:

serwer%

serwer% echo *

Arguments too long

serwer% ksh

$ echo *

file1

file2

....

file 10000

% exit

serwer%

Upvotes: 1

brianegge
brianegge

Reputation: 29892

You can see you current command length maximum with this command:

$ getconf ARG_MAX
1048320

I've created a script which can determine the maximum length of a remote command. As Craig suggested, your best bet is to pipe the command in to standard in, if that's an option.

Upvotes: 3

Jonathan Leffler
Jonathan Leffler

Reputation: 754550

When I run configure on Solaris 10 and the configure script comes up with a figure for the length of the command line, the answer is normally in the 256 KB range. The standard shells on Solaris most certainly do not have a limit under 300 bytes.

That said, I'm not sure what your problem is. I might hazard a guess at the Solaris SSH having a shorter limit - I've not encountered the problem, but I tend to use SSH as a way to connect directly (interactively) rather than to run long commands.

Upvotes: 0

Craig Trader
Craig Trader

Reputation: 15679

As I see it, your choices are:

  1. Change which shell you use on Solaris, by changing the default for the user.
  2. Don't change the shell, but change the way you run the commands.

The first is easy, but requires an administrator to make a change for every user/machine combination, and may affect other programs. Changing the way you run commands will be faster, and easier to maintain in the long run. As an example, suppose you need to execute the following:

/usr/bin/foo with a very long list of options and parameters

Right now you're probably doing something like this:

ssh user@machine "/usr/bin/foo with a very long list of options and parameters"

But you could do the following instead:

echo "/usr/bin/foo with a very long list of options and parameters" | \
ssh user@machine "/bin/bash"

This will do what you want.

Upvotes: 1

warren
warren

Reputation: 33453

I believe (though may be wrong) that's related to the default shell you're connecting to. If you make the change on Solaris to the same shell you're using on Linux, does that fix the problem?

Please comment if there's a better route to a solution, and I'll make the change in my answer.

Upvotes: 2

Related Questions