I would like to read from the file on SUT (MAC OS 10.4.10).
the file is located in Applications/Test/ws.properties.
I tried the following:
put “/Applications/Test/ws.properties” into versionFile
open file versionFile for reading
put “” into versionLine
read from file versionFile until return
if it is empty then exit repeat
put the last item delimited by tab of it into versionLine
close file versionFile
I have two problems with the above script:
it reads from the similar file located on the Eggplant server machine (not from SUT)
and it only return the last line in that file:
The file looks like this:
The intention of the script was to return 4 0 32
But it only returns prod_number=32
Any help will be greatly appreciated!
To read a file from a SUT, you can do a multitude of things.
Open file on SUT with an editor, and copy paste to the clipboard and to your local Eggplant environment (use Eggplant commands, as well as RemoteClipboard() functions to script for this.)
Could SSH to your remote system and ‘cat’ the contents from that file (use the SenseTalk shell(“ssh …”) to accomplish this.)
If the file is mounted locally (something you would have to do), you can treat that file as it were a local file and read/write as long as you have such permissions (use standard SenseTalk file management or container commands for this).
To split and parse a file like you mentioned try this:
set path to "/tmp/data.txt"
set ( maj, min, prod ) to last item delimited by "=" of \
each line of lines 1 to 3 of file path
put maj, min, prod
which outputs the following:
Wed, 9/19/07 5:35:28 PM START Running Main.script
Wed, 9/19/07 5:35:28 PM SUCCESS Execution Time 0:00:00 Main.script
when the data file looks like this:
MacBook17:~ todd$ cat /tmp/data.txt
We hope you find this useful.
Thanks for your help,
After opening a file, I am using REmoteClipboard() function to get the file contents and then I just parse the contents to get the data I need. It works fine now.