The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 8:34pm
Pages: 1
Send Topic Print
ocean script how to print an aliased path (Read 2609 times)
Zorro
Community Member
***
Offline



Posts: 63

ocean script how to print an aliased path
Jun 07th, 2011, 5:05am
 
hello all,

I do have a question regarding ocean scripts. it is probably very basic but I'm new to linux and the shell. hope someonce can help me.

if I type:
cd /design/libs/at77000/dev/

the command takes me to this directory (by typing pwd):
/design/libs/at77000/v0.9

i.e. "dev" is defined to take me to the newest version (some kind of an alias?), in this case to the directory v0.9

in fact if I go one directory up to /design/libs/at77000 and I do "ll" I can see: dev -> v0.9/

I am using ocean scripts and for documentation it is important for me to print/show which version is been used in the simulation

so I am doing something like this. first I define:

model_path="/design/libs/at77000/dev/"

and then:

fprintf(out "\n\n Version Used: %s \t" model_path)


it's working, but the output file shows:
Version Used: /design/libs/at77000/dev/

so my question is how to show the current version directory "v0.9" instead of "dev", i.e. I need to print this:
Version Used: /design/libs/at77000/v0.9/

the version is changing from time to time and that's why the path is defined as "/design/libs/at77000/dev/"

thank you very much and if you need more info please let me know.

regards!
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: ocean script how to print an aliased path
Reply #1 - Jun 8th, 2011, 5:31am
 
Zorro,Zorro wrote on Jun 7th, 2011, 5:05am:
... i.e. "dev" is defined to take me to the newest version (some kind of an alias?), in this case to the directory v0.9

in fact if I go one directory up to /design/libs/at77000 and I do "ll" I can see: dev -> v0.9/

I am using ocean scripts and for documentation it is important for me to print/show which version is been used in the simulation.
...
model_path="/design/libs/at77000/dev/"

Try Code:
system(strcat("cd " model_path " ; pwd")) 



B O E
Back to top
 
 
View Profile   IP Logged
Zorro
Community Member
***
Offline



Posts: 63

Re: ocean script how to print an aliased path
Reply #2 - Jun 9th, 2011, 4:49am
 
thank you for your suggestion boe!

I found a solution. the command "readlink"  was the key!

I added these lines:

[color=#9900cc][color=#0000ff]file_out=sch_name.out ; output file name
out=outfile(file_out "a") ; define and open the output file for writing


fprintf( out "Model Version used for this simulation" )
setShellEnvVar("var_out=") ; reset environment variable $var_out
setShellEnvVar(strcat("var_out=" file_out )) ; set environment variable $var_out to out_dir
csh(" readlink -f /design/libs/at77000/dev >> $var_out ") ; write model version into output file
[/color][/color]

now the output file has the new 2 lines included:
[color=#0000ff]
/design/libs/at77000/v0.9
Model Version used for this simulation
[/color]

Thanks for your attention and suggestions!

Regards!
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.