How have you validated that IP spoofing is not working? Have you tried to get the Vuser IP and place it in an output message? For example:
char *vuser_ip;
vuser_ip = lr_get_vuser_ip();
if (vuser_ip)
lr_vuser_status_message("The Vuser is spoofed with the following ip : %s",vuser_ip);
else
lr_vuser_status_message("The Vuser is not spoofed");
LR - Extracting a dynamic value hidden in javascript code
What function is used to extract a dynamic value hidden in javascript code? The value is required in order to complete a web_submit_data POST method parameter set.
Here's the script:
"5091228" is the dynamic value to extract.
Sorry about the javascript no-wrap posting. Reformatted for readability:
Hidden or not, you use web_reg_save_param to grab this dynamic value. If it is returned, it can be correlated.
I'm trying to do just this, but it is not working. I have a web_custom_request("shared.js") statement embedded in a web_concurrent
/* -------------------------------------------------------------------------------
Script Title :
Script Description : This script is to read database
Recorder Version : 1435
------------------------------------------------------------------------------- */
vuser_init()
{
/* declare variables*/
int rowincrement=1,TextCheck, i, j;
unsigned long RowCount = 0;
unsigned long * const count = &RowCount;
char *ItemName[500];
char *LastStatus[500];
/*conenction*/
lrd_init(&InitInfo, DBTypeVersion);
lrd_open_context(&Ctx2, LRD_DBTYPE_ODBC, 0, 0, 0);
lrd_db_option(Ctx2, OT_ODBC_OV_ODBC3, 0, 0);
lrd_alloc_connection(&Con2, LRD_DBTYPE_ODBC, Ctx2, 0 /*Unused*/, 0);
lrd_db_option(Con2, OT_ODBC_LOGIN_TIMEOUT, (void FAR const *)15, 0);
lrd_db_option(Con2, OT_ODBC_SS_QUOTED_IDENT, "OFF", 0);
lrd_db_option(Con2, OT_ODBC_SQL_PACKET_SIZE, (void FAR const *)4096, 0);
lrd_db_option(Con2, OT_ODBC_SS_ANSI_NPW, "ON", 0);
lrd_open_connection(&Con2, LRD_DBTYPE_ODBC, "", lr_decrypt("4a27962de"), "", lr_decrypt("4a27962d886b524e097fae09a52c595022c32775d6ac53b7"
"26f4c6e52c4aa7fe8f4655f2adb12dbd4fc99008542f41c6eda3e1f7ffdd"
"4ca7fd2ae0febd73f541202ac2db1e21eb822ec0b977225a45f3e20ad309"
"fb1996549d468df8a0d89bf8f6efdd5a21e8dcc3304c7b"), Ctx2, 1, 0);
/*cursor*/
lrd_open_cursor(&Csr2, Con2, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "set showplan_all off\r\n", -1, 1 /*Direct exec*/, 0 /*None*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_stmt(Csr2, "use [CAR]", -1, 1 /*Direct exec*/, 0 /*None*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lr_think_time(10);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
/*sql query*/
lrd_stmt(Csr2, "select * from item_status\r\n", -1, 1 /*Direct exec*/, 0 /*None*/, 0);
lrd_bind_cols(Csr2, BCInfo_D21, 0);
/* get the row count*/
lrd_fetch(Csr2, -8, 1, count, PrintRow2, 0);
lr_output_message("count= %d",*count);
/*lr fetch to verify if the data is coming in the frid*/
for(i=1; i<=("count= %d",*count); i++)
{
lr_output_message("%d",i);
lrd_save_col(Csr2, 2, i, 0, ItemName[i]);
lrd_save_col(Csr2, 3, i, 0, LastStatus[i]);
lrd_fetch(Csr2, 1,1 , 0, PrintRow20, 0);
lr_start_transaction(ItemName[i]);
/*condition to check the status*/
if (LastStatus[i]=="Up")
{
lr_end_transaction(ItemName[i], LR_PASS);
}
else
{
lr_end_transaction(ItemName[i], LR_FAIL);
}
}
lr_start_transaction("ItemFetch");
lrd_fetch(Csr2, -14, 1, 0, PrintRow20, 0);
GRID(20);
lr_end_transaction("ItemFetch", LR_AUTO);
/* close all the connections and cursors*/
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
return 0;
}
Merge all CSV or TXT files in a folder in one worksheet
Ron de Bruin (last update 5-July-2007)
Go back to the Excel tips page
1: Non VBA example from Dave Peterson
2: VBA example I made based on Dave's example
Example 1
Merge all data from the csv files into a text file
Note: with a few small changes you can also use this for txt files. Replace *.csv for *.txt
1) Windows Start Button | Run
2) Type cmd and hit enter ("command" in Win 98)
3) Go to the folder with the CSV files (for help enter "help cd")
4) Type copy *.csv all.txt and hit enter to copy all data in the files into all.txt.
5) Type exit and hit enter to close the DOS window
Now we must import the text file all.txt into Excel.
1) Open Excel
2) When you use File Open to open all.txt the Text Import Wizard will help you import the file
3) Choose Delimited
4) Next
5) Check Comma
6) Finish
Example 2
This code will ask you to browse to the folder with the csv files and after you click OK in this dialog
it merge all data into a txt file and then import and save it into a Excel file for you.
Copy the code below into a normal module of a workbook :
Alt-F11
Insert>Module
Paste the macro
Alt q to go back to Excel
Alt F8 to open your macro list
Select Merge_CSV_Files and press Run
There is no need to change anything in the code example for csv files to test it.
But read the Tips below the macro if you not get the result you want.
' Start Code
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103
Public Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long
'fill in the missing parameter and execute the program
If IsMissing(WindowState) Then WindowState = 1
hProg = Shell(PathName, WindowState)
'hProg is a "process ID under Win32. To get the process handle:
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
'populate Exitcode variable
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub
Sub Merge_CSV_Files()
Dim BatFileName As String
Dim TXTFileName As String
Dim XLSFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim DefPath As String
Dim Wb As Workbook
Dim oApp As Object
Dim oFolder
Dim foldername
'Create two temporary file names
BatFileName = Environ("Temp") & _
"\CollectCSVData" & Format(Now, "dd-mm-yy-h-mm-ss") & ".bat"
TXTFileName = Environ("Temp") & _
"\AllCSV" & Format(Now, "dd-mm-yy-h-mm-ss") & ".txt"
'Folder where you want to save the Excel file
DefPath = Application.DefaultFilePath
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If
'Set the extension and file format
If Val(Application.Version) < 12 Then
'You use Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
FileExtStr = ".xlsx": FileFormatNum = 51
'If you want to save as xls(97-2003 format) in 2007 use
'FileExtStr = ".xls": FileFormatNum = 56
End If
'Name of the Excel file with a date/time stamp
XLSFileName = DefPath & "MasterCSV " & _
Format(Now, "dd-mmm-yyyy h-mm-ss") & FileExtStr
'Browse to the folder with CSV files
Set oApp = CreateObject("Shell.Application")
Set oFolder = oApp.BrowseForFolder(0, "Select folder with CSV files", 512)
If Not oFolder Is Nothing Then
foldername = oFolder.Self.Path
If Right(foldername, 1) <> "\" Then
foldername = foldername & "\"
End If
'Create the bat file
Open BatFileName For Output As #1
Print #1, "Copy " & Chr(34) & foldername & "*.csv" _
& Chr(34) & " " & TXTFileName
Close #1
'Run the Bat file to collect all data from the CSV files into a TXT file
ShellAndWait BatFileName, 0
If Dir(TXTFileName) = "" Then
MsgBox "There are no csv files in this folder"
Kill BatFileName
Exit Sub
End If
'Open the TXT file in Excel
Application.ScreenUpdating = False
Workbooks.OpenText Filename:=TXTFileName, Origin:=xlWindows, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True, _
Space:=False, Other:=False
'Save text file as a Excel file
Set Wb = ActiveWorkbook
Application.DisplayAlerts = False
Wb.SaveAs Filename:=XLSFileName, FileFormat:=FileFormatNum
Application.DisplayAlerts = True
Wb.Close savechanges:=False
MsgBox "You find the Excel file here: " & vbNewLine & XLSFileName
'Delete the bat and text file you temporary used
Kill BatFileName
Kill TXTFileName
Application.ScreenUpdating = True
End If
End Sub
' End code
No comments:
Post a Comment