18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Change directories - Linux

TSheeleyTSheeley Members
edited January 2014 in Sahi - Open Source
Hello,

I am attempting to change directories when running a script(under Linux Ubuntu). I have attempted _execute(); but this does not like the "cd" command, and gives the error message "java.io.IOException: Cannot run program "cd": java.io.IOException: error=2, No such file or directory". Can you give any suggestions?

Best Answer

  • I would recommend you put everything to be execute in a dedicated .sh file. From the testscript you can run
    _execute("sh pathToYourScript/toExecute.sh", true);
    
    Notice the second parameter which will make Sahi wait for the execution to finish.
    Use absolute paths. Relative paths are relative to the script file in which the _execute is called.

    Can I help you any further?
    Regards
    Wormi

Answers

  • Thanks Wormi,

    You are always so helpful. I'll give this a try and get back to you.

    T
  • Ok, - You can move this to my "Mirth Connect Administrator 2.2.2.6388 - Java Web Start" discussion if you wish.

    Here is the scenario. We are posting xml messages, and I want to get the response. It's never in a browser, so I want to do this from the (Linux) console. I wanted to change directory, because when I run under sahi (using CURL and other external commands), everything is from the userdata/bin directory, and I didn't want to add anything there.

    So, I wanted to change directory to where I store my XML files. Then I wanted to do the POST and and retrieve the response from the console. I have now given up on changing directory, and I have gotten as far as being able to do ALL of this, IF I do it from the command line.

    So I wrote a quick shell script. Problem is, it never appears to work when I try it via sahi.

    Example code:

    var $postTxt = _readFile("Data/XML/curlAdmission1.sh"); // This works

    _execute("sh "+ $postTxt, true);

    var $retrieveTxt = _readFile("Data/XML/Post1.txt"); // This does NOT work

    Shell script:

    echo yes | curl -X POST -d @Data/XML/TestADTAdmissionMessage2.xml --noproxy 172.18.73.42 http://172.18.73.42:9034/Mirth/processMessage --header "Content-Type:text/xml" > Post1.txt

    Sahi reports the run as successful, but the file is NEVER created when run via sahi. I have searched the entire drive for it several times. This ALWAYS works if I run the shell script via the command line. Help????
Sign In or Register to comment.