getUlimitValues() function sending linux commands to windows

6 posts by 2 authors in: Forums > CMS Builder
Last Post: August 16, 2011   (RSS)

Re: [ITI] getUlimitValues() function sending linux commands to windows

By Dave - August 11, 2011

Hi Glen,

Thanks for the bug report! What PHP version and windows version are you running? We develop on Windows but haven't seen that error to date.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] getUlimitValues() function sending linux commands to windows

By ITI - August 11, 2011 - edited: August 11, 2011

Hi Dave
What PHP version and windows version are you running?


Operating System: Windows Server 2003 R2 Standard Edition
PHP Version: PHP v5.2.12

ps. A lot of times the error text is not visible but I would guess that it appears about 30% of the time and as I mentioned its not always the same place. The last time that it occured before I decided to investigate and fix it was when it showed up in the edit list of the "Restore Backup"

Select 'sh' is not recognized as an internal or external command, operable program or batch file. Select version to restore

Glen







http://www.CanadianDomainRegistry.ca







ITI Internetworking Technologies Inc.

Re: [ITI] getUlimitValues() function sending linux commands to windows

By Dave - August 15, 2011

Hi Glen,

That's really odd. shell_exec() actually shouldn't output any errors at all. It's only suppose to return any output and not even return error output unless STDERR is redirected to STDOUT.

I found a few PHP bugs that looked related but nothing conclusive:
https://bugs.php.net/bug.php?id=21065
https://bugs.php.net/bug.php?id=46399

Are you running anything particularly unique or different on the server?

Can you try the attached script and let me know what the output is? Maybe try refreshing a few times to see if you can get the extra error output to appear in the page somewhere.

I'm thinking the simple fix may be to just add 2>&1 to the end of the command to capture any error output. Even though it shouldn't be being output anyways maybe that would prevent the issue.

Let me know what you find out, thanks!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] getUlimitValues() function sending linux commands to windows

By ITI - August 15, 2011 - edited: August 16, 2011

Hi Dave

There are no abnormal server settings.

I ran the script independent of CMSB as well as, as a Notice() from within the General Settings page.

The results were as one would expect.

The error message seems to want to appear around the Data Base Section but not consistently in the same places.
Some times beside the button, once as the button text, then as a select item in the Restore Data Base list etc... but I've also had it appear near the top of the page as well.

Anyway, adding the redirection "2>&1" does seem to solve the problem.
I've tested it as many ways as I can and do not see the error appearing anywhere.

I think you have the right solution with the redirection. The redirection certainly doesn't affect anything since the error message doesn't match any of the regex expressions.

I'll leave my system running with the redirection and should the error re-appear I'll let you know but I think it's safe to say you solved it.
For those that are experiencing this problem, this is where Dave as put the redirection.
// get shell command
if ($type == 'soft') { $cmd = 'sh -c "ulimit -a -S" 2>&1'; }
elseif ($type == 'hard') { $cmd = 'sh -c "ulimit -a -H" 2>&1'; }


I have another bazar issue but I'll post it as a new item.
Glen







http://www.CanadianDomainRegistry.ca







ITI Internetworking Technologies Inc.

Re: [ITI] getUlimitValues() function sending linux commands to windows

By Dave - August 16, 2011

Ok, sounds good. I'll add 2>&1 for the next release.

Thanks!
Dave Edis - Senior Developer
interactivetools.com