Topic: Help Help! Need to remake registered task script to download emaisl from imap server to mysql db (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30841" title="Pages that link to Topic: Help Help! Need to remake registered task script to download emaisl from imap server to mysql db (Page 1 of 1)" rel="nofollow" >Topic: Help Help! Need to remake registered task script to download emaisl from imap server to mysql db <span class="small">(Page 1 of 1)</span>\

 
paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-14-2009 14:04

Help guys! My old idea of using a php page that downloads emails from the online imap server into our db and refreshes constantly is clumsy and backfires every now and then. I need to remake this stupid script again. I tried making a bat file which would call iexplorer to open the download script but for some damn reason the bat file isn't called periodically and teh stupid scheduled task thing just skips calling it now and then.

I'm open to any solution for this. I have my php classes here and code that can download from an online imap server - serialise the contents into objects and store in a database. However I need a sure fire way to run it as a cron or scheduled task. I don't want this to keep failing on me - I'm open to all options now man.

What do I do here guys? If I need to code in php to be executed in the command line - what should I consider when coding? Or if there is another way to do so - please I need to know man.

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 02-14-2009 19:19

Sorry, what do you need these email addresses for?

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-14-2009 19:51

Not email addresses - let me rephrase what I was saying. We have an imap server - we have a php script that connects to the imap server and downloads all emails - note emails not email addresses - emails belonging to one address in a mailbox and serializes the contents as objects and enters them in a database. Well the script works fine but the thing is that we nee dto fix up a fool proof method to run this script on a periodic basis. We tried making a batch file and opening IE from that file calling the script within it. However for some reason the scheduled task dies out on us for some reason.

Is there anyway for us to run a script like this periodically without any interruptions I mean that as a scheduled task that faithfully runs periodically. I really need help on this pronto man

Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

posted posted 02-14-2009 21:39

http://www.hiveminds.co.uk/?p=35223

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 02-14-2009 22:58

I asked you a couple of questions the last time and they went unanswered. Let me ask again.

Are you running this as a scheduled task in windows?
If so, does the script run when you call it from the command line?
If so, does it not run when the computer is logged in?

If you so, then the account that you gave permissions to run the task is not set in the local security policy for "Log on as batch job" and "Log on as service"

If not...then I am not sure.

Later,

C:\

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-15-2009 06:09

Hmm must have skipped my mind - sorry bout that. Well the code is kinda like this below - I have a vbs file and a bat file which calls the vbs file:

Vbs file

code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'iexplore.exe'")
isbusy = 0

IE = false
Set oShApp = CreateObject("Shell.Application")
	
	For Each oWin In oShApp.Windows

	t = TypeName(oWin.Document)
	On Error Resume Next
		IE = 1
	Err.Clear
	
	
		If t = "HTMLDocument" Then
			Set IE = oWin
			Exit For
		End If
Next

if IE <> false then
	if IE.busy then
		isbusy = 1		
	end if
end if

if isbusy = 0 then
	
	For Each objProcess in colProcessList
				objProcess.Terminate()
	Next
		
	Set WshShell = WScript.CreateObject("WScript.Shell")
	Return = WshShell.Run("iexplore.exe http://localhost/modules/download.php", 1) 
end if



bat file

code:
start closeIE.vbs

cls

exit



The bat file is called by the task scheduler. The thing is that on its own it runs fine - infact it runs fine even with the task scheduler - however I noticed if I come back to check the status after like lets say a few hours - the task scheduelr although is set it wont call the batch file and keeps skipping. Whats wrong here?

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 02-15-2009 10:41

chances are it's still running and that's why the task schedulder doesn't start it again...


Seriously, you are never going to built a reliable system based on an unnecessary
multi layer architecture where IE is one of the layers

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-15-2009 11:45

Hmm well I'm thinking of trying to get rid of use for IE for this - using IE was just a monkey wrench solution until we figured something concrete - seems it didnt last as long as we were hoping. Need to then fix up my download script to be run from command line then - however is there anything I need to change in coding in order to run it successfully on teh command prompt.

The last time I tried it - I got some include related errors - cant recall right now. I've included loads of files however some of them are like relative includes i.e. include('../../config.php')

What do I do here and whats the right way to code something like this... is the relative path include causing the problem here?

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 02-15-2009 19:11

you have long ago worn out my glass ball, parity.

Yes, relative paths might be the problem, because they're not relative to the included file, but relative to the script being run,
but they might not be. You simple haven't given us any information.
(If they are, replacing them with dirname(__FILE__). '/../.....' based constructs might help).

So long,

->Tyberius Prime

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 02-15-2009 19:14

look at the log for the task scheduler for errors.

Later,

C:\

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-15-2009 20:06

Well what kind of further information should I post btw I really need help here - and am willing to tell what ever else is needed

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 02-15-2009 20:11
quote:

paritycheck said:

Well what kind of further information should I post btw I really need help here - and am willing to tell what ever else is needed



well...you can post the log of the bat file if it errors. That would help.

Later,

C:\

Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

posted posted 02-15-2009 21:45

parity did you try wget?

I gave you a link with instructions but I'm sure you didn't read it.

1) just download this thing
2) create a bat file:
wget.exe -q -O nul http://www.website.com/folder/cron.php
3) schedule it with windows scheduler

... and see what happens ... no vb/vbs or IE required ...

(Edited by Arthurio on 02-15-2009 21:45)

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-16-2009 06:55

Great lemme try these out - sorry I did check the early post - didn't try it out though - would give what all you guys have given a shot and will let u know in a while....

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 02-16-2009 11:25

How about the bloody actual error messages you get when running your script on the command line?

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 02-16-2009 14:12
quote:

Tyberius Prime said:

How about the bloody actual error messages you get when running your script on the command line?



ugh....That's what I am talking about. I know you need help paritycheck, and I am willing to help with what I can. But it is virtually impossible to know what the problem is without the error(s).

Later,

C:\

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-16-2009 14:26

Ok I fixed it YIPPEEEE - I guess its kinda late to give the error messages but the errors were all fatal include could not find path errors. Primarily because I was including using relative paths. The issue being that the bat file which calls the script is in a different folder than the script itself was leading to issues. Had it resolved by changing the relative paths includes to referring to paths using dirname(dirname(__FILE)) as Tyberius said.

Now its working great when I call from the command prompt though I now have to test and monitor it for running as a scheduled task. I want my task to run as such that it executes every 3 minutes such that when 3 minutes pass it should check if the bat is still running - if so then it should skip and again check after 3 minutes and execute if the bat has already done its job.

However I would like to know that if we are to upload this to a third party server - are there any provisions to running our own scheduled tasks or cron jobs there as well?

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 02-16-2009 15:25

cron jobs are usually available when you rent dedicated hosting... how new are you in this business, actually?

paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 02-17-2009 06:55

Umm well I've been developing for over 5 years - however I'll be honest with you - I havent registered a simgle domain or web host so far and this practically is gonna be my first . I just did the programming and tested it on local host and the most I'd do was make sure it was working online.

Domain registration and setting up the web host was always dealt with by someone else - practically I've just worked on 3 humongous web applications in 3 years [I guess you may have understood the precarious nature of the applications I'm working on and add to that my boss's everchanging list of requirements]. I must be one of a rarity among web developers - 5 years of experience in programming the most weirdest situations but have no experience with domain registration, web hosting and even working in e-commerce



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu