About Me

My photo
Over nine years of research experience in social science and public health research, who specializes large scale survey design and analysis, and data quality in various forms and tools of research work with Quantitative as well as Qualitative techniques and then last five years I have developed data entry and tabulation package in CSPro for various large scale surveys in India as well outside India. Presently I am working as Consultant State Data Manager in UNICEF Chhattisgarh (Through PDCSL).

Tuesday, April 5, 2011

Using execsystem to Retrieve a Computer's Username

visit counter for blogspot

An example of when this could be useful is if you want to create a PFF file with the data file named after the login ID of the keyer who has logged onto that machine.

PROC GLOBAL


alpha (20) tempFilename = "tempusername.txt";

alpha (300) str;

FILE inputFile;

alpha (50) username;


PROC EXAMPLE

execsystem(maketext('cmd /c "set username > %s"',strip(tempFilename)),wait);

setfile(inputFile,strip(tempFilename));

fileread(inputFile,str);

close(inputFile);

filedelete(strip(tempFilename));

// str looks like this: USERNAME=pedro

username = str[poschar("=",str) + 1];

errmsg("Computer username is %s",strip(username));

No comments:

Post a Comment