Re: g_option_context_parse under cron execution



--- Richard Boaz <riboaz xs4all nl> wrote:

> Hi,
> 
> I am using the following code to parse my routine's command line:
> 
> gboolean parsePQLXargs(int argc, char **argv, PQLXSRVRSTRUCT *pqlxSrvr)
> {
>   gboolean	ret=TRUE;
>   GOptionContext *context;
>   GError 	*error = NULL;
>   static GOptionEntry entries[] =
>   {
>     { "dbName", 0, 0, G_OPTION_ARG_STRING, NULL, "PQLX Database Name",
> "[SERVER:]pqlxDB" },
>     { "numCPU", 0, 0, G_OPTION_ARG_INT, NULL, "Number of CPUs to use", "#" },
>     { "identFile", 0, 0, G_OPTION_ARG_STRING, NULL, "File Containing List
> of Traces to be Re-Analyzed", "path-to-file" },
>     { NULL }
>   };
> 
>   entries[0].arg_data = &pqlxSrvr->pdfSrvr;
>   entries[1].arg_data = &pqlxSrvr->numCPUS;
>   entries[2].arg_data = &pqlxSrvr->identFile;
>   context = g_option_context_new ("- Execute pqlxSrvr");
>   g_option_context_add_main_entries (context, entries, NULL);
>   g_option_context_add_group (context, gtk_get_option_group (TRUE));
>   if (!g_option_context_parse (context, &argc, &argv, &error))
>   {
>     if (error)
> 	fprintf(stdout, "parse error: %s\n", error->message);
>     else
> 	fprintf(stdout, "parse failed, there is no error\n");
>     ret = FALSE;
>   }
>   return ret;
> }
> 
> Everything works fine when the program is executed directly from a command
> line.
> 
> However, when executed via a cron job, g_option_context_parse() returns
> FALSE, i.e., failure.  Except the error structure is still NULL, i.e., no
> error is set as a result of this failure.
> 
> So my questions:
> 
> 1) why does g_option_context_parse() fail when executed under cron?
> 2) why is there no error set on this failure?
> 
> Does anyone use the glib command line parser under a cron execution? 
> Search by google found no references to this particular combination being
> problematic and at this point I must simply write my own command line
> parser since cron execution is an absolute requirement for me.
> 
> Any pointers appreciated.  If this should be regarded as a bug, let me
> know, I'm happy to log a report.
> 
> cheers,
> 
> richard
> 

Have you tried to replace (temporarily) you program with something simple
written in, say, Perl or "C" that just prints ARGV ?

I mean, can it be that somehow wrong arguments are passed to your
program from 'cron' ?

--Sergei.


Applications From Scratch: http://appsfromscratch.berlios.de/


       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]