Interview Questions

Need to get file size for a file present on Unix machine , thr' silktest at run time. How to get it ?

SilkTest Questions and Anwsers


(Continued from previous question...)

89. Need to get file size for a file present on Unix machine , thr' silktest at run time. How to get it ?


Answer1:
SilkBean is used for working in unix...I haven't used it....See help...the steps for silk bean settings are mentioned there....
Otherwise, considering telnet window (whatever used for connection) as a DialogBox, automate the steps using TypeKeys()..

Answer2:
I guess SilkBean can be used ONLY with Java based applications :-?
I saw help in ST help .... as it looks too much .. for my simple task of getting a *file size *of one of the file on Unix machine ...
I would like to know the WAYs i can get file size OR properties of a file on Unix machine through ST ?
Anyways , but SilkBean looks nice solution for same ..
also how can i execute some application thr' ST ? lets say cmd prompt < * cmd.exe >*

Answer3:
Use SYS_Execute ("C:/Vaibhav/xyz.exe") if xyz.exe is lying at C:/Vaibhav
For standard commands there is no need to separately invoke Dos Command Prompt.....
e,g SYS_Execute ("echo %USERNAME%", lsOutput) would return the user name in the lsOutput variable...

Answer4:
How would you do this if you were running the test manually?
I suspect that you would open a terminal application and perform an ls -l You might also pass that through grep or awk.
We use cygwin under windows to perform bash shell scripts here so here's what I would do
You may need to create a system variable for your path to cygwin binaries or one directly to bash.exe, but if you install it normally, the bin directory will be exposed to the command line environment.
ls -l /\/\servername\path\filename | gawk '{print $(6)}'
encase that in a SYS_Execute () and parse the results
[ ] INTEGER iFileSize = SYS_Execute ("ls -l /\/\servername\path\filename | gawk '{print $(6)}'",lsSysResult)
You're set.
I haven't tried this, but it should work.

Answer5:
If its only a file size u need, and need to get it from a telnet session, read on....
putty is a windows client with which one can connect to a Unix/Lx m/c using standard telnet or ssh. Its easy to automate this UI on windows. If you enable logging to a file (the file saved on the windows client), all the telnet session is captured to this file. One can then get the file size or whatever the results of the commands run on the unix m/c over telnet. Even easier is the Hyper Terminal Program which comes with Windows.
Both PUTTY and HTERM give you a Windows UI and not the cmd prompt, which some people may find hard to automate

(Continued on next question...)

Other Interview Questions