Operating System - OpenVMS
1748205 Members
4888 Online
108759 Solutions
New Discussion

Re: Error while executing the script

 
Mrityunjoy Kundu
Frequent Advisor

Error while executing the script

Hi,

 

My purpose is to display the content of test.txt on screen when test1.com executes. I tried to write the procedure but it stuck on "say"  during execution.

 

Please see the below script and let me know where I am worng.

 

 

$ SET noon
$ inquire env1 "Enter Env1 "
$ inquire env2 "Enter Base "
$ sea sys$login:housekeep.com 'env1'_'env2'/out=test.txt
$ open/read headlist test.txt
$ open/write repfile1 test1.com
$ read/end_of_file=done headlist inline
$ write repfile1 "$ say :== "write sys$output" "
$ write repfile1 "$ say  "Modify ''env'_'''env2'_config.dat and Execute the Below Command "
$ write repfile1 "$ say ''inline'"
$close repfile1
$ close headlist
$ exit

 

 

test.txt contains the below line

 

$@sys$startup:pwc_startup A F 310 T L

6 REPLIES 6
Hein van den Heuvel
Honored Contributor

Re: Error while executing the script

>>  but it stuck on "say"  during execution.

 

Did you mean "But it generates the following error during execution of a line with "say" on it:"

%DCL-W-UNDSYM, undefined symbol - check validity and spelling
\SYS$OUTPUT \

 

So you are writting a script which writes a script?

Those are a little tricky, because any quote that needs to appear in the target script needs to be a double quote in the source script. That get's worse if you need to do the substitutions in the target,which it appears you do not need.

 

Why the second script? Why not just do the deed? (those write sys$outputs)?

I guess this is just a miminal snippet from a larger solution where the second script is unavoidable?

 

Anyway here is the corrected script. Works for me, even rhough it does not seem too useful.

 

$ SET noon
$ inquire env1 "Enter Env1 "
$ inquire env2 "Enter Base "
$ sea sys$login:housekeep.com 'env1'_'env2'/out=test.txt
$ close/nolog headlist
$ open/read headlist test.txt
$ open/write repfile1 test1.com
$ read/end_of_file=done headlist inline
$ write repfile1 "$ say :== ""write sys$output"""
$ write repfile1 "$ say  ""Modify  ''env1'_''env2'_config.dat and Execute the Below Command """
$ write repfile1 "$ say  ""''inline'"""
$done:
$ close/nolog repfile1
$ close/nolog headlist
$ exit

 Enjoy,

Hein.

 

John McL
Trusted Contributor

Re: Error while executing the script

Why create a second command procedure?  Would the code below do what you want?

 

$ SET noon
$ inquire env1 "Enter Env1 "
$ inquire env2 "Enter Base "
$ write sys$output "For any lines listed below, modify  ''env1'_''env2'_config.dat and Execute the Command"

$ search sys$login:housekeep.com 'env1'_'env2'

$ if $severity.nes."1" then write sys$output "  (no lines to correct)"

$ exit 

This will display it all on the screen, just like creating an running a new command procedure will do. If it's important to get the entire output into a file then execute the procedure with /OUTPUT=<filename>.

 

By the way, I recommend against using abbreviations in command procedures.  Typing them in full (which you'll only do once) makes it much easier to read the code.

 

Jansen_8
Regular Advisor

Re: Error while executing the script

The number of "quotes" seems not to be correct: The following works for me: $ write repfile1 "$ say :== ""write sys$output"" " $ write repfile1 "$ say ""Modify ''env1'_''env2'_config.dat and Execute the Below Command "" " $ write repfile1 "$ say ""''inline'"" " Jouk
H.Becker
Honored Contributor

Re: Error while executing the script

As already pointed out, there is some trouble with double double and double (or was it triple?) single quotes. You can avoid much of the doubling, you just need it once and have to pay for it with an extra blank:

 

...

$ open/write repfile1 test1.com
$ read/end_of_file=done headlist inline
$ write repfile1 "$ say=""write sys$output """""""
$ write repfile1 "$ say Modify 'env'_'env2'_config.dat and Execute the Below Command"
$ write repfile1 "$ say 'inline'"
$ close repfile1
...
 
But what do I know whether your post was just an extract from a bigger script, ahem command procedure, where this simplified quoting technique can't be applied.
Mrityunjoy Kundu
Frequent Advisor

Re: Error while executing the script

Thanks a lot..jist one more thing to ask.

 

I want to display the below on inline on second file

 

"$ @sys$startup:prd_startup  sys  dev  717 F "" PRD  abc_STARTUP "

 

$show sym inline 

 

it is showing the correct valuse

 

 

but while redirecting to another file

 

$ write repfile1 " say ""''inline'""

 

it is showing as :

 

"$ @sys$startup:prd_startup  sys  dev  717 F " PRD  abc_STARTUP "

 

 

double quote is replaced by single quote.

 

 

 

H.Becker
Honored Contributor

Re: Error while executing the script

You are using symbol substitution within a string, that is, in

 

$ write repfile1 " say ""''inline'""

(there is a missing, closing double quote for the string, but DCL for convenience adds one, here)

 

inline is replaced, which results in

 

 

$ write repfile1 " say ""$ @sys$startup:prd_startup  sys  dev  717 F "" PRD  abc_STARTUP """

 

After DCL replaced all double double quotes within the string, WRITE gets this string (which I here delimit by <> to make it more obvious)

 

< say "$ @sys$startup:prd_startup  sys  dev  717 F " PRD  abc_STARTUP ">

 

which WRITE writes into your file.

 

Try

 

$ write repfile1 " say """, inline

 

That is, let WRITE write a string and a symbol.

 

You can use that for all your WRITEs to the repfile1:

...

$ write repfile1 "$ say :== ""write sys$output"""
$ write repfile1 "$ say  ""Modify  ",env1,"_",env2,"_config.dat and Execute the Below Command """
$ write repfile1 "$ say  """,inline,""""
...
 
Presumed env1 is prd and env2 is startup, this results in test1.com to contain:
 
$ say :== "write sys$output"
$ say  "Modify  prd_startup_config.dat and Execute the Below Command "
$ say  "$ @sys$startup:prd_startup  sys  dev  717 F "" PRD  abc_STARTUP " 
 
However, if you run this, it results in
 
$ @test1
Modify  prd_startup_config.dat and Execute the Below Command 
$ @sys$startup:prd_startup  sys  dev  717 F " PRD  abc_STARTUP 
$ 
 
which is probably not what you want. You may need to do more quoting or reconsider how to solve the original problem.

 

(I did some cut&paste and formatting here - which is not easy with the supplied tools in this forum - and hope I didn't drop anything especially any quote.)