Re: Re: how to schedule my task

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

 



On 26 Dec 2005 06:58:40 -0000, Navdeep <singh_nav00@xxxxxxxxxxxxxx> wrote:
>
> On Sun, 25 Dec 2005 gb spam wrote :
> > >  I created a GUI application on QT 3.1 on red HAT LINUX. Now i want to run this application automatically just after log in as ROOT. How can i do this . If I want to run my application daily at 4:30 PM then what to do for it.
> > >
> > >  I tried it using cron but  could not successful . Any idea will be appriciable.
> >
> >cron does not have a display associated with it, so your gui app will
> >die.  check root's mail, by default all output (errors in this case)
> > from the job will be mailed to the user.
> >
> >you could try the following:
> >
> >DISPLAY=:0.0
> >
> >in the script, but you'll need to do some xhost stuff for each user
> >that may be logged in on the GUI.
>
>
> OK , I have no idea to write AND COMPILE THE scripting language.
> But  i tried in below fashion at sch.sh file
>
> #!/bin/sh
> sh /root/QT/QTDesigner/scheduler/scheduler
> DISPLAY=:0.0
>
>
> Now i tried to run it by # sc sch.sh  but it says
>
> : cannot execute binary file
>
>
> How to come out this problem
>
> Regards

You are succesfully calling the script but it is failing when it
reaches the second line.

In your script you call your binary QT application as:
sh /root/QT/QTDesigner/scheduler/scheduler

This will definitely not work and that is the cause of your "cannot
execute binary file" message.

If I understand correctly, scheduler is not a shell script. 
Therefore, when calling it in a script all you need to do is
/root/QT/QTDesigner/scheduler/scheduler

If you call "sh <file>" then the sh shell will try to open the file
and execute it as a shell script.

Also, you will need to set any environment variables _before_ calling
your program.

I would rewrite your script like this:

#!/bin/sh
MY_PROGRAM_DIR=/root/QT/QTDesigner/scheduler/scheduler
DISPLAY=:0:0
export DISPLAY
cd MY_PROGRAM_DIR
./scheduler

# end of script

BTW, I agree with other posts suggesting that writing a GUI app to run
a scheduled task is a bad idea.  You have no idea if :0.0 will be a
valid display when the script is run, also, you won't know to whom it
belongs.

--
Kind regards,

John Francis


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux