VuGen: Open A File On A Remote Machine

The user wants to open a file existing on a remote machine in VuGen, but using the fopen function causes a C interpreter error. What this error means is that there was something wrong in the syntax, but the problem comes up only when file is stored in the remote machine.

The host name itself contains two backslashes as a part of the name. So, in order to specify the complete path of the host machine, you need to precede each backslash with another backslash.

NOTE: when adding script to Controller, you need to add yourfile.txt to Controller -> Details…-> More -> files

EXAMPLE:
This should be the correct way of writing a open:

int *fp;
fp=(int *) fopen("\\\\machine_name\\shared_name\\dir_name\\filename","attribute");
 
Alternative solution
Alternatively, you can insert your file in the script directory, then specify full path of the file in the vuser directory on the remote machine using the function lr_get_attrib_string("usr"). For example,
 
long stream;
char file_path[100];
Action1()
{
 
    sprintf(file_path,"%s\\yourfile.txt",lr_get_attrib_string("usr"));
    if((stream = fopen(file_path,"r" ))!=NULL)
 
    {
        lr_output_message(file_path);
        fclose( stream );
    }
 
    else
    lr_output_message("the file can't be opened");
 
    return 0;
}

——————————-

Scott

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events