Re: g_option_context_parse under cron execution
On 10/3/07, Richard Boaz <[EMAIL PROTECTED]> wrote: > as indicated in the documentation example. Looking into the details of > the call gtk_get_option_group(TRUE), TRUE is an indication that the > default display should be opened when parsing the command line. > > So under cron, this fails, naturally. You're right, you'd expect this to set the error to "can't open display" or somesuch. Perhaps you could file a bug on that? It sounds like it should be an easy thing to fix if you have some time spare. John ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: g_option_context_parse under cron execution
Hi John, Thanks. Going through the exercise of providing a small example, the cause of the problem became known: I had included the following call when setting up the context: g_option_context_add_group (context, gtk_get_option_group (TRUE)); as indicated in the documentation example. Looking into the details of the call gtk_get_option_group(TRUE), TRUE is an indication that the default display should be opened when parsing the command line. So under cron, this fails, naturally. I do not need the gtk command line options in my program (nor a display), so simply removing this line makes everything work as required and expected. thanks, richard p.s. i still think, however, the error structure should be set; an error occurred and the call to parse fails, why can't i know why? (thus avoiding bothering this list?) On 10/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... I think the error must lie elsewhere, though I'm not sure exactly where. Can you make a tiny standalone main.c that shows your problem? John ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: g_option_context_parse under cron execution
On 10/3/07, Richard Boaz <[EMAIL PROTECTED]> wrote: > 1) why does g_option_context_parse() fail when executed under cron? > 2) why is there no error set on this failure? I just tried and it works fine for me. I added this with "crontab -e": 50 * * * * /home/john/vips/bin/run-nip2.sh --version > /tmp/nip.out run-nip2.sh is a wrapper script that sets LD_LIBRARY_PATH and friends so my app picks up the environment it expects. I think the error must lie elsewhere, though I'm not sure exactly where. Can you make a tiny standalone main.c that shows your problem? John ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: g_option_context_parse under cron execution
--- Richard Boaz <[EMAIL PROTECTED]> wrote: > Yes, I've fully debugged the cron-executed version. All arguments are > identical to when executed from the command line, i.e., are properly > constructed and fully valid. > > I was wondering, too: Does this particular glib routine require there be a > display available? Still, I would expect the error structure to be filled > if this were the case, but maybe not? > > richard > > On 10/3/07, Sergei Steshenko <[EMAIL PROTECTED]> wrote: > > 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. > Well, in addition to DISPLAY environment variable I would also check the importance/availability of STDIN. --Sergei. Applications From Scratch: http://appsfromscratch.berlios.de/ Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. http://sims.yahoo.com/ ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: g_option_context_parse under cron execution
Yes, I've fully debugged the cron-executed version. All arguments are identical to when executed from the command line, i.e., are properly constructed and fully valid. I was wondering, too: Does this particular glib routine require there be a display available? Still, I would expect the error structure to be filled if this were the case, but maybe not? richard On 10/3/07, Sergei Steshenko <[EMAIL PROTECTED]> wrote: 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. ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: g_option_context_parse under cron execution
--- Richard Boaz <[EMAIL PROTECTED]> wrote: > Hi, > > I am using the following code to parse my routine's command line: > > gboolean parsePQLXargs(int argc, char **argv, PQLXSRVRSTRUCT *pqlxSrvr) > { > gbooleanret=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/ ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list