Batch file to tidy up contents of LoadRunner script folder

After you finish using LoadRunner scripts, lots of files can be left behind in the script folder, these include output files, error logs and the compiled script. Provided that you know your script works, they can be removed before you archive your scripts to save space on your file server.

 

I use this batch file to tidy up the files that I don’t need.

Paste the text below into a notepad.exe or a similar text editor and save it as a file called “tidyup.bat“.
Copy tidyup.bat into the script folder and run it to tidy up the files in that folder. The script uses the /s switch which means that this script recurses through all sub directories and tidies up files in script sub-folders.

 

After deleting files, it opens notepad.exe and displays the list of deleted files.


@echo off

REM simple menu system

CLS


;START

cls

echo.

echo This batch file will delete the following files from every

echo folder and subdirectory from the folder in which it is run: –

echo.

echo *.idx

echo mdrv*.log

echo mdrv.txt

echo options.txt

echo *.ci

echo combined_*.c

echo output.txt

echo debug.inf

echo *.bak

echo.

echo.

echo It will then output a list of what it deleted to: –

echo [c:FilesDeleted.txt]

echo.


if exist c:FilesDeleted.txt del c:FilesDeleted.txt


del *.idx /s >c:FilesDeleted.txt

del mdrv*.log /s >>c:FilesDeleted.txt

del mdrv.txt /s >>c:FilesDeleted.txt

del options.txt /s >>c:FilesDeleted.txt

del *.ci /s >>c:FilesDeleted.txt

del combined_*.c /s >>c:FilesDeleted.txt

del output.txt /s >>c:FilesDeleted.txt

del debug.inf /s >>c:FilesDeleted.txt

del *.bak /s >>c:FilesDeleted.txt


“Notepad.exe” “c:FilesDeleted.txt”

del c:FilesDeleted.txt

 

How to drop multiple tables in MySQL

After an experiment with a MediaWiki Wiki on my website, I decided that I preferred to use Joomla for my site content. I needed to delete the Wiki content to free up some space.

Deleting the wiki folder was easily done through FTP.
Deleting the database tables had the potential to be time consuming.
I used this SQL to find all the relevant tables and delete the WIKI tables with SQL statements.

 

SHOW TABLES LIKE ‘wiki%’

Returned a list of tables like this….

wiki_archive

wiki_categorylinks

wiki_externallinks

wiki_hitcounter

wiki_image

wiki_imagelinks

wiki_interwiki  etc. etc.

 

Using a text editor (I like TextPad from Helios Software), create SQL to drop each table in the list.

 

drop table wiki_archive;

drop table wiki_categorylinks;

drop table wiki_externallinks;

drop table wiki_hitcounter;

drop table wiki_image;

drop table wiki_imagelinks;

drop table wiki_interwiki; etc. etc.

 

This deletes all the tables at once.

 

 

 

 

 

 

C Function – Add five minutes to current time

I needed to write a function which added five minutes to the current time in a LoadRunner script. This allowed a script to simulate appointment bookings for a web application.

The function could be modified to add more or less time, the clever bit was making sure that it handled the last few minutes of an hour properly.

For example.
13:56 + 5 minutes = 14:01

The function handles this by converting the 13 and the 56 into integers, doing the necessary sums and then converting the results back into strings which LoadRunner can use.

When the integers are converted back to strings, single digit number are displayed correctly e.g. 01,02,03 etc. rather than 1,2,3.

The function will not work in the last five minutes of the day because I haven’t added a function to add five minutes to 23:56 to get 00:01. (If you’re running tests this late, don’t use this function).

Action()

{

int iCurrentHour;

int iCurrentMinute;

int iTotalMinutes;

int iNextHour;

int iNextMinute;


char sTimeNow[6];

char sTimeInFiveMins[6];

char sTemporaryTimeValue[3];

char sCharCurrentHour[3];

char sCharCurrentMinute[3];

char sCharNextHour[3];

char sCharNextMinute[3];



lr_save_datetime(“%H”, TIME_NOW , “sCurrentHour”);

lr_save_datetime(“%M”, TIME_NOW , “sCurrentMinute”);

// Uncomment these next two lines if you need to test the function using alternative times.

// lr_save_string(“12”, “sCurrentHour”);

// lr_save_string(“58”, “sCurrentMinute”);


//Convert Hour and Minute into iHour and iMinute (integers)

//Convert Hours into Minutes

iCurrentHour = atoi(lr_eval_string(“{sCurrentHour}”));

iCurrentMinute = atoi(lr_eval_string(“{sCurrentMinute}”));


//Add 5 minutes to the current time

iNextHour=iCurrentHour;

iNextMinute=iCurrentMinute+5;


//If after the 54th minute in the hour, add 1 hour to the “hour” time and take 55 minutes off the “minute” time

if (iCurrentMinute>54)

{

iNextHour=iCurrentHour+1;

iNextMinute=iNextMinute-60;

}


//Convert integers back into strings

//The “if” statements make sure that the times are formatted correctly after the maths has been done.

//e.g. Five past One in the morning is 01:05, instead of 1:5

lr_save_int(iCurrentHour,”sCurrentHour”);

if (strlen(lr_eval_string(“{sCurrentHour}”))<2)

{

strcpy(sTemporaryTimeValue, “0”);

strcat(sTemporaryTimeValue, lr_eval_string(“{sCurrentHour}”));

sprintf(sCharCurrentHour, “%s”, sTemporaryTimeValue);

lr_save_string(sTemporaryTimeValue, “sCurrentHour”);

}


lr_save_int(iCurrentMinute,”sCurrentMinute”);

if (strlen(lr_eval_string(“{sCurrentMinute}”))<2)

{

strcpy(sTemporaryTimeValue, “0”);

strcat(sTemporaryTimeValue, lr_eval_string(“{sCurrentMinute}”));

sprintf(sCharCurrentMinute, “%s”, sTemporaryTimeValue);

lr_save_string(sTemporaryTimeValue, “sCurrentMinute”);

}


lr_save_int(iNextHour,”sNextHour”);

if (strlen(lr_eval_string(“{sNextHour}”))<2)

{

strcpy(sTemporaryTimeValue, “0”);

strcat(sTemporaryTimeValue, lr_eval_string(“{sNextHour}”));

sprintf(sCharNextHour, “%s”, sTemporaryTimeValue);

lr_save_string(sTemporaryTimeValue, “sNextHour”);

}


lr_save_int(iNextMinute,”sNextMinute”);

if (strlen(lr_eval_string(“{sNextMinute}”))<2)

{

strcpy(sTemporaryTimeValue, “0”);

strcat(sTemporaryTimeValue, lr_eval_string(“{sNextMinute}”));

sprintf(sCharNextMinute, “%s”, sTemporaryTimeValue);

lr_save_string(sTemporaryTimeValue, “sNextMinute”);

}



lr_output_message(“The current time is %s:%s”,lr_eval_string(“{sCurrentHour}”),lr_eval_string(“{sCurrentMinute}”));

lr_output_message(“The time in 5 minutes will be %s:%s”,lr_eval_string(“{sNextHour}”),lr_eval_string(“{sNextMinute}”));


return 0;

}