Home > Community > Forums > Custom IC SKILL > Assign Shell output to Ocean variable

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Assign Shell output to Ocean variable 

Last post Wed, Dec 5 2012 9:25 AM by The Setlaz. 6 replies.
Started by The Setlaz 05 Dec 2012 06:26 AM. Topic has 6 replies and 1017 views
Page 1 of 1 (7 items)
Sort Posts:
  • Wed, Dec 5 2012 6:26 AM

    • The Setlaz
    • Top 500 Contributor
    • Joined on Wed, Dec 5 2012
    • Saggart, Dublin
    • Posts 36
    • Points 520
    Assign Shell output to Ocean variable Reply

    Hi,

     

    I'd like to assign a shell command (sh or csh) output to an OCEAN variable but the problem is that Shell always return "t" and nothing else.

     

    I would need to be able to get the results of a "pwd | cut -d "/" -f 8" command (that returns the name of my testbench which is the same as my testbench-cellview) where my script is loaded from, and put the results of this command in an OCEAN variable so that I can paste the name to the right directory to open all my result in batch.

     

    My script would look like this :

     ----------------------------

    newWindow()

    corner_list='("corner_1" "corner_2" "corner_3")

    simDir = "/home/my_name/path/to/all/testbench/"

    testbench = sh("pwd | cut -d "/" -f 8")

    foreach(corner corner_list)

    openResults( strcat( simDir "/" testbench "/" corner ) )

    selectResults( 'tran )

    )

    -------------------------

     

    This script would be automatically load all my corner PSF results in Cadence Results Browser for "familly plot" without editing the script to change the testbench name inside before running it.

     

    Thanks !

    Damien

    • Post Points: 20
  • Wed, Dec 5 2012 6:35 AM

    Re: Assign Shell output to Ocean variable Reply

    Damien,

    Two ways:

    ipcId=ipcBeginProcess("pwd | cut -d '/' -f 8")
    ipcWait(ipcId)
    testbench=ipcReadProcess(ipcId)

    Simpler is to do this though:

    nthelem(7 parseString(getWorkingDir() "/"))

    This avoids launching any child process.

    Andrew.

    • Post Points: 20
  • Wed, Dec 5 2012 7:18 AM

    • The Setlaz
    • Top 500 Contributor
    • Joined on Wed, Dec 5 2012
    • Saggart, Dublin
    • Posts 36
    • Points 520
    Re: Assign Shell output to Ocean variable Reply

     Hi Andrew,

     

    Thanks a lot !! I almost get it working. I used the nthelem command

    When I execute my script interactively in a shell running Ocean, it works fine.

    But when I try to execute the script from ICFB  it tells me :

    *Error* strcat: argument #2 should be either a string or a symbol (type template = "S") - nil
    *Error* load: error while loading file - "/home/my_name/path/to/all/testbench/my_testbench/plot.ocn" at line 8

     

    My script is as following :

    testbench = nthelem(7 parseString( getWorkingDir() "/" ) )

    Line 8 : simDir = strcat("/home/my_name/path/to/all/testbench/" testbench "/my/results")

     

    I don't understand why it works interactively (awd.exe version 5.1.0) but not when I load the script (icw 6.1.5)

     

    Thanks again,

    Damien

    • Post Points: 20
  • Wed, Dec 5 2012 7:49 AM

    Re: Assign Shell output to Ocean variable Reply

    If the directory doesn't have enough delimiters (i.e. "/") then the nthlem will return nil. What does getWorkingDir() return in each case - the working and nonworking cases?

    Andrew.

     

    • Post Points: 20
  • Wed, Dec 5 2012 9:03 AM

    • The Setlaz
    • Top 500 Contributor
    • Joined on Wed, Dec 5 2012
    • Saggart, Dublin
    • Posts 36
    • Points 520
    Re: Assign Shell output to Ocean variable Reply

     Hi Andew,

     

    Indeed, in the non-working case,nthelem returns "nil"

    Interactively (i.e the working case), it returns the full path as expected.

     

    Any clue about what can cause different behavior ?

     

    Thanks

    Damien

    • Post Points: 20
  • Wed, Dec 5 2012 9:19 AM

    Re: Assign Shell output to Ocean variable Reply

    Damien,

    I asked what getWorkingDir returns, not what nthelem returns. It was obvious from the error that nthelem must have returned nil.

    Can you show that in each case?

    Regards,

    Andrew.

    • Post Points: 20
  • Wed, Dec 5 2012 9:25 AM

    • The Setlaz
    • Top 500 Contributor
    • Joined on Wed, Dec 5 2012
    • Saggart, Dublin
    • Posts 36
    • Points 520
    Re: Assign Shell output to Ocean variable Reply

     Oops, my mistake !

     

    getWorkingDir() does not return the expected path (unsurprisingly...). It returns the path from which I launched ICW (/home/my_name) whereas I expected to get the path where the script is loaded from.(/home/my_name/path/to/all/testbench/my_testbench/)

     

    Thanks a lot,

    Damien

    • Post Points: 5
Page 1 of 1 (7 items)
Sort Posts:
Started by The Setlaz at 05 Dec 2012 06:26 AM. Topic has 6 replies.