• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Reading back the output of a Unix command

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 12374
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reading back the output of a Unix command

TZoltan
TZoltan over 3 years ago

I am currently looking into how to interface Virtuoso/SKILL with other scripts, which can be executed from the Linux/Unix command line. I would like to invoke a python script of mine and use the value it prints into the stdout in my SKILL script. I've found an article in the support site, which uses IPC inside the CCSRunCmd script, and there is an example python script called AddNum.py there as well. My problem is that the return value of the script is not displayed in CIW, nor can it be stored into a variable.

Is it this script broken now? Or what am I missing? The python file exists, I've checked with isFile(), and also opened with vi(). The script runs as intended if I copy the argument of CSSRunCmd, i.e. "python3 /home/my_user_name/bin/AddNum.py" into the csh terminal.

CCSRunCmd("python3 /home/my_user_name/bin/AddNum.py")
t

Thanks,
Zoltan

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    Hi Zoltan,

    Check the return value of getSkillPath(). If this doesn't contain "." in it, the CCSRunCmd won't find the file myFile in the working directory. This is not new behaviour - it's been that way in SKILL forever, that infile uses the SKILL path.

    You can workaround it by using:

    CCSRunCmd("python3 /home/my_user_name/bin/AddNum.py" "./myFile")

    Explicitly giving the file name with a path at the beginning addresses the issue. Of course, you could change the default in your definition of CCSRunCmd too.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • TZoltan
    TZoltan over 3 years ago in reply to Andrew Beckett

    Thanks Andrew,

    Somehow invoking python with CCSRunCmd does not produce any output in my environment. I've tried CCSRunCmd out with a very simple command, and it saved into a file as it supposed to:

    strCmd2="echo \"foobar\" > foo.bar"
    "echo \"foobar\" > foo.bar"
    CCSRunCmd(strCmd2)
    foobar
    t

    I can not imagine what could have gone wrong invoking python, but the problem seems to be there, and not in the CCSRunCmd script.

    Is there any way to see all the stdout and stderr outputs of the command executed with ipcBeginProcess? I assume if python fails, CCSRunCmd won't show me the error message. It might be needed to debug this issue on our side.

    Thanks and best regards,
    Zoltan


    -----------------------------------------------
    Anything below this line is just a record of what I've done. They are probably not relevant any more.
    "." is in the skill path. Defining the output file where the output will be stored does not change the behaviour, even if I define it with absolute path. This file is created, but the output is not stored there. If I understand the code right (and it does not seem complicated) a Linux command is executed with ipcBeginProcess, ipcWaitForProcess waits until the output is ready (including writing into the file with output redirection), and after that it reads in the contents of the output file ("myFile" by default).

    CCSRunCmd returns with three "t\n". I've executing the commands in the CIW manually line by line as well. Still the myFile is empty. 

    The SKILL script uses the output redirection of the shell, and it works as expected from the csh command line:

    $ python3 ~/bin/AddNum.py > tmp.out
    $ cat tmp.out
    The sum of 1 and 2 is 3.0

    I am using the following SKILL/Virtuoso versions:
    getSkillVersion()
    "SKILL37.00"
    getVersion()
    "@(#)$CDS: virtuoso version ICADVM20.1-64b 11/30/2021 18:40 (cpgsrv12) $"

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • TZoltan
    TZoltan over 3 years ago in reply to TZoltan

    For anybody having the same issue: You can redirect the stderr output to the file as well with '>&', instead of '>' in CSH/TCSH. If the error should go into a different file, use a command like `sh("(python3 ./AddNum.py > myFile.out) >& myFile.err")`. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mbracht
    mbracht over 3 years ago in reply to TZoltan

    Hi Zoltan,

    The problem wirg CCSRunCmd is that any potential error messages get lost along the way because '>" redirects stdout only (and not stderr).
    So to get at the root cause why your python script isn't running can you please do this:

    cmd = <your pythonScript>
    id=ipcBeginProcess(cmd)
    ipcWaitForProcess(id)
    (while out=(ipcReadProcess id) (println out))

    That way you capture both the errors as well as the regular messages. Make sure that you pass the absolute path of your python script.

    Max

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • TZoltan
    TZoltan over 3 years ago in reply to mbracht

    This will drive CIW into an endless loop...

    Anyway, I've posted ways to redirect stderr into stdout or into a file. It gave the information I needed to solve the issue.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to TZoltan

    You should use (ipcReadProcess id 1) or something like that - giving a timeout matters to stop it getting stuck.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information