RunWithNewResults in a doc.txt

Hi Eggplant Team, I am a new eggplant user since 2 months and I just love it. I have a problem and I need your help please.
I start my master script like this
Create doc.txt
RunWithNewResults script
Put it into doc.txt.

But it doesnt work, it just create the file and when i check it in after it is empty. I would like to create a text document and then instead of having the results saved in my suite folder, i want it to be saved in that doc. Please I need your help with the code.

Thank you

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    You can't redirect the results in this way. You can write specific messages to a file by using put or write commands in your script, or you can specify a global results folder in the settings for a suite, to which all the script results will be written. Since you are using the RunWithNewResults command, you could achieve what you are trying to do like this:
    RunWithNewResults script
    copy file the result.logfile to "doc.txt"
    
  • Thanks a lot Matt, but actually I am wondering why it doesnt work.
    The only thing it does is to create the folder with the file inside, but when i check after, the file is empty.
    Here is what i've made



    Create file "/Documents/doc.txt"
    Open file "/Documents/doc.txt" for writing
    RunWithNewResults script
    copy file the result.logfile to "/Documents/doc.txt"
  • Actually it works,
    I,ve just tried it as foollow and it works perfectly. But please How can I do if I dont want it to oveeride each timeit will run , I want the next results to go to the next line. Also how to let the system send me the results via email.

    RunWithNewResults Script
    Put the result into MyResults
    log "SomeScript.script succeeded. Making note of this in the data file"
    put MyResults into line 1 of file "Documents/Results/datafile.txt"

    Thanks
  • EggplantMattEggplantMatt ForumAdmin admin
    It doesn't work because you're not using the code as I posted it. There's no need to create the file or open it for writing, and the fact that you have it open for writing is why you can't copy the file created by eggPlant to that location. The code I posted was complete -- it just copies an existing file to a new location. Even if you were going to write to a file, in eggPlant you don't have to create the file or open it for writing (you can, but it's not necessary) -- eggPlant takes care of that for you. So you can just say:
    put "This is some text" into file "/path/to/myfile"
    
    And if myfile doesn't exist at the specified location, eggPlant will create it. You can use "put after" to append to an existing file, and "put before" to insert at the beginning of one (either will also create the file if it doesn't exist and the location is writeable). Just "put" will erase existing contents and replace them with the specified value or create a new file if there isn't an existing one.
  • EggplantMattEggplantMatt ForumAdmin admin
    How about this:
    runwithnewresults somescript
    put the result into myResult
    copy file myResult.logfile to ("~/" & the short name of the folder of myResult.logfile & ".txt")
    
    This uses the dynamically generated folder name to give the file a unique name.

    As for emailing you the file, you'll need to use the sendmail command, which is fully documented in the eggPlant Reference.
Sign In or Register to comment.