tags:

views:

1823

answers:

4

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?

+2  A: 

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.

warren
You are correct, the issue is with the default shell (sh). Is there a way to change the command line limit for sh? I can't change to another shell right now
Josh Clark
+1  A: 

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.

Craig Trader
A: 

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.

Jonathan Leffler
A: 

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.

brianegge