Scripts (both in Java and Perl) to automate online status inquiry

king1999

Registered Users (C)
Scripts to automate online status inquiry

This thread is for people to post their automated scripts for online status checking, so that you don't have to manually do it every 10 minutes. :D I will post my perl script, and people can follow with their beloved creations in VB, C#, etc.
 
perl script to check online status

To make it work, you need the following:

1. Perl from http://activeperl.com/
2. cURL and openSSL from http://curl.haxx.se/

I set it up on Windows 2000 but it should work on Linux or other platforms with some simple changes.

The portions of code you need to customize are enclosed with lines of "#########".

On Windows you can use "Scheduled Tasks" to set up automatic runs, and on Linux you have cron.

(See the next post for a Linux version)
 
Linux version

Here is a version by alsowaiting and his original post:

Here it is.

Note that I added a 'chdir()' command, so that I can use local names for the file locations. I put the script in $HOME/tools/uscis myself, and all temporary files of the script are put in there too.

So, you need to fill in your name, twice an email addres, an smtp server, a SRC number (or edit more to include more SRC numbers), and a directory where you want the temp&status files.

I have curl version 7.10.8 and perl 5.8.2 (Debian Sid).

Make sure you put the temp files somewhere where there are correct write permissions regarding the crontab entry you made for it..

Ths is the line that I added to my user crontab ('crontab -e', assuming user=alsowaiting) to make the script run every hour at 15 minutes after the hour:

15 * * * * /home/alsowaiting/tools/uscis/inquire_bics.pl
 
thx king1999

dear fresh new green card owner - king1999, thx for the codes, i will load it now for my plastic card lottery informing, hope your codes will run for me next week :D

thx again, enjoy your freedom life and you deserve it :p
 
error...

King1999...cplusplus...

I unzipped openssl.exe to my C:\ drive along with all the other files. When I try to run the perl script I get an error "curl.exe is not recognized as an internal or external command, operable program or batch file"

Can you please tell me what I am doing wrong? Thanks for your help...
 
Re: error...

Originally posted by bkd52
King1999...cplusplus...

I unzipped openssl.exe to my C:\ drive along with all the other files. When I try to run the perl script I get an error "curl.exe is not recognized as an internal or external command, operable program or batch file"

I think you need to install curl (if not done so) and then edit the script to point to the correct locations of the files.
 
need help on the Perl

Dear king1999, bkd52,
Thank you very much. I am not Perl programer. I never use Perl before. Would you please help me to setup the perl to run this scripts?
the following is what I did, but it doesnot work.
My computer runs Windows2000.
in windows200, have C,D,E,F 4 Hard Drives
1. I donwload the curl-7.11.0-win32-ssl.zip, unziped it to c:\curl\ming32
2. download perl to f:\perl
create all the folders on my hard Drivs needed in the following scripts:
$status_file = "F:\\BICS_status.html";
$old_status_file = "F:\\BICS_status.";
$curl = "C:\\cURL\\ming32\\curl.exe";
$logfile = "F:\\SysTools\\scripts\\485check.log";
$history = 'F:\\SysTools\\scripts\\history';

I copy the Scripts to f:\scripts folder,
go to start-run-(type cmd)
type F:
cd\scripts:
F:\scripts>perl inquire_bics.pl
got the following error message:

The dynamic link library libeay32.dll could not be found in the specied path c:\cur\ming32, c:\winnt\system32;c:\winnt\system;c:\winnt;c:\winnt\system32\wbem;
c:\program files\ActiveState Komodo 2.5\


What should I do?
I only wnat to run this script to check on line status. If you can post step by step how to download the software need, how to install, how to create the directory and how to run the
script, it would be wonderful, I know some people is not IT field, but what to setup and run the scripts.

Thank you
 
johnjohn:

You need to download openSSL (from the same download page as cURL) which contains the dll you mentioned.
 
Re: Using Net::SMTP instead of curl...

Originally posted by samXadams
king1999,

You may want to use the Net::SMTP package available in Active Perl. Then you don't need to install curl also.

Here is a link with an example:
http://perl.about.com/library/weekly/aa022000d.htm

Scroll down to see the example script.

Regards.
-- Sam

Thanks Sam.

Somebody has posted another perl script without using cURL a couple weeks before. Those who are interested can search back. For me, the cURL way has been working fine.

And the Perl motto is "There is more than one way to do it!", by Larry Wall. :cool:
 
Thank you king1999, The Perl Scripts works for me now!
For someone can not use the SMTP from the ISP (eg. Hotmail, yahoo email accouint), You can download a Free SMTP server software at: http://www.postcastserver.com/. I download and installed it. it works.
Thanks you all.
 
Script not working - partially

I have installed the script and everything ( all required software ). The script works for the first time in that it sends the email and also generates the files. But if I invoke it for the second time, it does not generate the status files again ( I thought it was supposed to rename the old file and create a new status file - I know it wont send the email until something has changed ). Is that true even for the status file ? I thought it was being generated regardless of whether status has changed or not.
Please help.
 
Re: Script not working - partially

Originally posted by dallasgcwait
I have installed the script and everything ( all required software ). The script works for the first time in that it sends the email and also generates the files. But if I invoke it for the second time, it does not generate the status files again ( I thought it was supposed to rename the old file and create a new status file - I know it wont send the email until something has changed ). Is that true even for the status file ? I thought it was being generated regardless of whether status has changed or not.
Please help.

That's normal behavior.

If the status is not changed, the script only writes a line to the log file. It will not create a new status file (what's the point of creating a new one if everything is the same?). You can force it to write a new status file AND send out email by removing the history cache.

Basically you can check the log file to make sure the script has run.
 
i have been trying to get the pl script to work but the overheads woth installing PERL/CURL and the rest of the works on a windows machine has been killing me so i did a lift off ...

rewrote some code in VB and wanted to share the same...

read the query.ini file that is where all the info is

if u have bugs and questions feel free to email/PM me.

u might need the VB runtime files for now, i will try to slowly improve on it to make it more intelligent so it dowsnt need extra files, help me.. i have this script running and it sends me an SMS on my mobile 2 times a day 5 days a week, using windows task scheduler.


give it a shot

download the zip file, double clik on install.bat to run and install the DLL that sends the email then edit QUERY.INI using a text editor like NOTEPAD and put in ur information...
and run it... if need be set it up with task scheduler in windows
 
Java program for email notification of your change in case status

Hi Folks

This is a cool Java jar file which I wrote that will read all the case numbers entered in case.txt file and it will create a stat.txt file which contains case status. if there is a change in status after the initial checking, it will send a email to you notifying about the change in status. This program will keep checking the status after the delay milliseconds which you can set.

Step for installation

UNZIP inz.zip file
it should unzip the following files in c:\ins

ins.jar
ins.dat
case.txt
mail.jar
activation.jar


copy mail.jar and activation.jar to your C:\Program Files\Java\j2re1.4.2_03\lib\ext


edit ins.dat file as follow

infile=C:\\ins\\case.txt
outfile=C:\\ins\\stat.txt
datfile=c:\\ins\\stat.dat
smtp=smtp.xxx.xxx
to=your.name@xxx.com
from=your.name@xxx.com
delay=3600000

where
infile is the text input file containing case number one per line
outfile is the text output file containing case status.
datfile is a output file which hold the case status detail which i use for comparing changes.
smtp's value should be your mail server
from's value should be your email address in you mail server
to's value should be any valid email address where you want to send the change of status email, it can be same as your to's values.
delay is delay you want between each group of checkings, the program will check all case number and then it will be idle for the [delay]miliseconds and recheck agian. the delay is in milliseconds so 1000 mean 1 sec. I would suggest you keep a delay of 1 hours between checking, so the delay should be 3600000

ins.dat has to be in the same directory as ins.jar file.

stat.txt and stat.dat will be automatically created after the first case status checking is done.
stat.txt contains your latest case status after the last checking
stat.dat contains case status and is used by the program to check change in status.


Configure you exproler to associate .jar files with javaw.exe

Put a shortcut to the jar file in the startup of your windows and your are good to go.

it will keep checking your case status every delay miliseconds and if any case status change you will get email notification.


A portion of the code was copied from user KASHMIR's case status checking program, as i did'nt want to re-invent the wheel, thank to his effort

Let me know if this works for you, it does a good job for me.

To test if email notification works, you can change the status of any one case in stat.dat file, next time it check it will detect the change and send u email.



Thanks

TM
 
Last edited by a moderator:
Just made some more cosmetic changes to the program, now it will show countdown of remaing millisecond for rechecking, the display will change every 60000 milliseconds ie. 1 minute



Those who have download and installed, please let me know your feedback.

Thanks
 
Have u copied mail.jar and activation.jar to your C:\Program Files\Java\j2re1.4.2_03\lib\ext.

Make sure u run this program after you connect to internet, otherwise it will crash out with fatal error message.
 
Top