From: Gary on
I'm helping a fella in the UK with a debian build (tiny web) on a small VM
machine in a data center. I am trying to compile some c++ code, I have the
libs and binaries installed and the compile "works", except for this line...

I have a php file used to make the build, and the file contains these
lines..


system("g++ $files $incl $libs >& build.log");
# system("g++ $files $incl $libs");

The first line fails with an error "sh: Syntax error: Bad fd number".

If I comment out the first line, and uncomment the second line, I do get my
"a.out" file but the errors/warnings go to the screen... how can I make
them go to the 'build.log' file?

I have done full package updates on the system using Webmin, and everything
as of this morning is current.

Thanks kindly for any assistance you can provide. :)

Gary



--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/ANEAJGKDLNAAPMPGONLKKEAGCBAA.gary.mccallum(a)shaw.ca
From: Boyd Stephen Smith Jr. on
On Friday 30 April 2010 12:39:00 Gary wrote:
> I have a php file used to make the build, and the file contains these
> lines..
>
> system("g++ $files $incl $libs >& build.log");
> # system("g++ $files $incl $libs");
>
> The first line fails with an error "sh: Syntax error: Bad fd number".

That's because ">& build.log" is a bash-ism. If dash is installed as /bin/sh
(which is useful, since it executes the start-up scripts faster), you might
get this error.

You probably want "> build.log 2>&1" which (one of?) the standard, POSIX/SUS-
compatible way of re-directing both stdout and stderr to a single file named
"build.log". The ">&" shortcut that bash has is nice, but it is not portable.

The Single UNIX Specification, version 3 (and older versions) are available
for free from the owner of the UNIX trademark. Those documents can tell you
what to expect from the shell on any certified UNIX system. AFAIK, no Linux
has been certified yet, but they still remain an excellent guideline for Linux
systems.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss(a)iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
From: Gary on
system("g++ $files $incl $libs 2>build.log&");

The above works... thanks!

-----Original Message-----
From: I Rattan [mailto:ratta1i(a)cps.cmich.edu]
Sent: Friday, April 30, 2010 12:03 PM
To: Gary
Subject: Re: sh command issue




On Fri, 30 Apr 2010, Gary wrote:

> I'm helping a fella in the UK with a debian build (tiny web) on a small VM
> machine in a data center. I am trying to compile some c++ code, I have
the
> libs and binaries installed and the compile "works", except for this
line...
>
> I have a php file used to make the build, and the file contains these
> lines..
>
>
> system("g++ $files $incl $libs >& build.log");
2>1&

Might work.
ishwar



--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/ANEAJGKDLNAAPMPGONLKCEAHCBAA.gary.mccallum(a)shaw.ca
From: Jon Dowland on
On 30/04/10 19:34, Gary wrote:
> system("g++ $files $incl $libs 2>build.log&");

Note this is risky: the system call will return as soon as the g++
process is invoked, rather than when it completes - the trailing '&'
should be removed. Also, any stdout output will still hit your console
(although I presume, since things appear to be working, that there isn't
any/much stdout output)