Reading file on SUT

Hi,
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

repeat forever
read from file versionFile until return
if it is empty then exit repeat
put the last item delimited by tab of it into versionLine
end repeat

close file versionFile
return versionLine

I have two problems with the above script:

  1. it reads from the similar file located on the Eggplant server machine (not from SUT)

  2. and it only return the last line in that file:
    The file looks like this:
    major_version=4
    minor_version=0
    prod_number=32

The intention of the script was to return 4 0 32
But it only returns prod_number=32

Any help will be greatly appreciated!

Hello Anna,

To read a file from a SUT, you can do a multitude of things.

  1. 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.)

  2. Could SSH to your remote system and ‘cat’ the contents from that file (use the SenseTalk shell(“ssh …”) to accomplish this.)

  3. 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
4
0
32
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 
major_version=4
minor_version=0
prod_number=32

We hope you find this useful.

Hi Todd,
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.
Anna.