Sure you have read how to use system properly? But as I also said you might
want to look into using pipe instead since they may be disabling your ability
to pull system calls in your code. Your system(NULL) == 0 means the shell is
not available.
$man 3 system
SYSTEM(3) Linux ProgrammerΓÇÖs Manual SYSTEM(3)
NAME
system - execute a shell command
SYNOPSIS
#include <stdlib.h>
int system(const char *command);
DESCRIPTION
system()executes a command specified in command by calling /bin/sh -c
command, and returns after the command has been completed. During execution of
the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.
RETURN VALUE
The value returned is -1 on error (e.g. fork() failed), and the return
status of the command otherwise. This latter return status is in the format
specified in wait(2). Thus, the exit code of the command will be
WEXITSTATUS(status). In case /bin/sh could not be executed, the exit status
will be that of a command that does exit(127).
If the value of command is NULL, system() returns non-zero if the shell
is available, and zero if not.
:
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valnir
Sent: Friday, May 04, 2007 6:18 PM
To: [email protected]
Subject: RE: system calls failing
Ok... I've been playing with this a little and I've found something
interesting. Everything is resulting backwards. If I do system( NULL ) I get
a 0 (zero) instead of the non-zero it's supposed to return. When I do
system( "ls ../player" ) the output goes into the log and I get a non-zero
back instead of the 0 (zero) it should be returning.. somebody want to
explain this?
-Valnir
-----Original Message-----
From: Dale Kingston [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 19, 2007 5:29 PM
To: Nathan Kodak
Subject: RE: system calls failing
I would have to agree w/ Davion. You should try using pipe instead of
system, cause then you could see what's going wrong... Cause in this bit you
posted just looks like there is no such files at
`../../backup/v5.1/player/`.
Like they suggested try typing the commands exactly as the mud is from the
same folder the mud runs and see if that's the problem. And make sure it's
not a permissions problem as well.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valnir
Sent: Thursday, April 19, 2007 11:50 AM
To: 'Michael Barton'; [email protected]
Subject: RE: system calls failing
Ok.. I'm using system() because I'm doing actual shell commands, not just
file work. I did tell perror to spit out whatever it could fine and here's
what I got back... which boggles my mind since the folder and files are
there.
Thu Apr 19 13:43:25 2007 :: Log Valnir: pbackup
mv: cannot stat `../../backup/v5.1/player/*.gz': No such file or directory
pfile_backup: No child processes
Thu Apr 19 13:43:25 2007 :: [*****] BUG: NON-ZERO returned. Please check log
for errors.
-Valnir
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael
Barton
Sent: Thursday, April 19, 2007 12:25 PM
To: Nathan Kodak
Subject: Re: system calls failing
It could be a path issue. Have you tried specifying /bin/mv or
whatever explicitly?
What do you do with stderr? Something might be logged.
You might also check perror. Even though system() isn't documented as
using errno, it does make an underlying call to fork, exec, waitpid,
etc.
--Mike
On 4/19/07, Valnir <[EMAIL PROTECTED]> wrote:
> Hello again. I'm having another interesting error since we moved our game
to
> an in-house server. Any system calls we make (pfile backup, etc) are all
> failing with a error of -1. Does anyone have any idea why this would be
> happening? Could it have anything to do with the different GCC version?
The
> new server is running GCC 4.1.1 and everything seems to compile fine, but
I
> don't know if there's options that are disabled or what the problem is.
Any
> guidance would be appreciated.
>
> -Valnir
>
> /* code block */
> bool pfile_backup ( void )
> {
> char cmd[MSL];
> int i, errLevel;
>
> for ( i = 0; i < 4; i++ )
> {
> switch ( i )
> {
> case 0:
> sprintf( cmd, "mv -uf %s*.gz %s", BACKUP_DIR, BACKOLD_DIR
);
> break;
> case 1:
> sprintf( cmd, "rm -f %s*", BACKUP_DIR );
> break;
> case 2:
> sprintf( cmd, "cp -ufp %s* %s", PLAYER_DIR, BACKUP_DIR );
> break;
> case 3:
> sprintf( cmd, "gzip %s*", BACKUP_DIR );
> break;
> }
>
> if ( ( errLevel = system( cmd ) ) != 0 )
> {
> char buf[MSL];
>
> bug( "NON-ZERO returned. Please check log for errors.", 0 );
> wiznet("ERROR: System returned an error during pfile backup.",
> NULL,NULL,WIZ_SECURE,0,CREATOR);
> sprintf( buf, "ERROR: Failure occured at \"%s\" with error
%d",
> cmd, errLevel );
> wiznet(buf,NULL,NULL,WIZ_SECURE,0,CREATOR);
> return FALSE;
> }
> }
>
> return TRUE;
> }
>
> /* Game Output */
> 47665/47665hp 21571/21571m [-332] 8019 > pback
> Backing up files now...
> WizNET: [9:04] ERROR: System returned an error during pfile backup.
> WizNET: [9:04] ERROR: Failure occured at "mv -uf
> ../../backup/v5.1/player/*.gz ../../backup/v5.1/player_old/" with error -1
> Backup failed!!
>
>
> --
> ROM mailing list
> [email protected]
> Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom