Daily Script Limit

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Daily Script Limit

Post by CyberCitizen » Thu Jan 12, 2006 2:01 pm

Hello Guys / Girls,

I currently have a script which can be used to upload files to an FTP server.

What I am wanting to do is limit how many times it can be used to upload a file, this is to prevent flooding.

I am thinking of the Read/Write Line Command to create a file say in the users system directory or something similar.

Does anyone have a suggestion as to how this could be done, I want to limit them 3 uploads a day.

Any help with this would be great.
FIREFIGHTER

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 12, 2006 2:10 pm

Use a registry value or ini file.


//get upload count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
//if not already set, set to zero
If>count=
Let>count=0
Endif
If>countcount=count+1
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
..
.. rest of script here ....
..
Else
MessageModal>Upload limit reached ...
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Thu Jan 12, 2006 11:23 pm

Thank You For Your Help, I Don't Want To Use An Ini File As I Want To Keep It As One Exe, However I Could Always Have The Script Compile The Ini File.

The Script You Supplied Was Pretty Much What I Was Thinking, However Then How Would I Limit It For Only That Day, That Script Is Just Going To Continue To Check & The Count Is Only Going To Get Bigger.

Would It Be Something Like Create A Date Reg Key And Put In A Read Reg Key, Like If Date=Today Continue Else Let Date = blank.

I Know Its Not Code Above, Its More Of An Example, If You Think That Would Work, I Will Code It & Test It.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jan 13, 2006 5:51 am

Had a little spare time this evening so I took the liberty of modifying Marcus' code and added a date. I have the same with an ini file if you change your mind I could post it. The ini method is a little simpler for the date since you can use the ini file date as the last upload date.

Also, if you dare to do it and if your computers are on the same domain. You might consider setting the users computer date to the ftp server date. Otherwise, all a user would need to do to defeat your count is change the date on their computer. Maybe not worth the risk but the basics are remarked at the top of the script.




///set computer time to server time
///this can take a few moments
//Let>RP_WAIT=1
//Let>RP_WINDOWMODE=2
//Run>cmd /c net time \\[servername] /set /yes

//get upload count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Date,today
//if not already set, set date
If>today=
Day>dd
Month>today
Year>yy
Concat>today,%dd%%yy%
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Date,today
Else
///Set today
Day>dd
Month>date_today
Year>yy
Concat>date_today,%dd%%yy%
If>date_todaytoday
Let>count=0
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Date,date_today
EndIf
EndIf
//if not already set, set count
If>count=
Let>count=0
Endif

If>countcount=count+1
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
..
.. rest of script here ....
..
Else
MessageModal>Upload limit reached ...
Endif


Later,
Dick

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Thu Jan 19, 2006 5:22 am

Thank You For Your Help, Both Dick & Marcus.

I Have Got The Program/Script Working Exactly How I Want.

You Can View The Program Here: CyberCitizen's Demo Upload Tool
FIREFIGHTER

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts