0

I very new to ksh script but I have 2 ksh scripts each of them calling sybase stored procedure via isql. The issue I'm seeing is that when I execute the first script the stored procedure runs fine but when I execute the second it fails with error of (isql -b -S value -U value -P value: not found). Here are code snipets

Values for $SERVER, $DBO_USER and $DBO_PASSWORD are set earlier in the script.

test1.ksh:

ISQL_CMD="isql -b -S ${SERVER} -U ${DBO_USER} -P ${DBO_PASSWORD}"

VAR=`${ISQL_CMD} << EOF
set nocount on
go
set proc_return_status off
go
 declare @var_id int
       ,@rtnval   int

 exec @rtnval = DB_NAME..MY_STORED_PROC_1
                @parameter1 = ${VAR_IN}
               ,@parameter_output  = @var_id output
go
EOF`

This executes fine and I get value in VAR variable

test2.ksh (VAR variable gets passed in from test1.ksh):

ISQL_CMD="isql -b -S ${DSQUERY} -U ${DBO_USER} -P ${DBO_PASSWORD}"

RETURN_VALUE=`${ISQL_CMD} << EOF
set nocount on
go
declare @rtnval   int

exec @rtnval = DB_NAME..MY_STORED_PROC_2
                @var_id = '${VAR}' 
go
EOF`

I get the following error:

isql -b -S value -U value -P value: not found

These scripts can be run independent of each other so there is no guarantee that isql may have been called before test2.ksh and that is why I set the the ISQL_CMD variable in each script.

test1.ksh runs properly but test2.ksh does not, whether called from test1.ksh or run on it's own. Tried running the scripts in debug, but it didn't really provide any further information.

Michael Gardner
  • 6,406
  • 5
  • 21
  • 33
user1015196
  • 503
  • 5
  • 18
  • I have not run in debug and actually don't know how since I'm new to ksh. DSQUERY, DBO_USER and DBO_PASSWORD are currently set inside each of the scripts. They will be in environment files in production. Also if I remove the ISQL_CMD="isql -b -S ${DSQUERY} -U ${DBO_USER} -P ${DBO_PASSWORD}" from test2.ksh. It runs without error. Doesn't look like it runs the isql because I don't get any return value but I don't get error either. – user1015196 Jul 25 '13 at 18:50
  • figured out how to set debug....but didn't really provide me any further information. – user1015196 Jul 25 '13 at 19:01
  • Done that as well and there are no difference in the variables. I was able to run the Sybase successfully so I've ruled that out. Any other suggestions? One other note, so test2.ksh does not run whether executed from test1.ksh or executed independently so it is definitely something wrong with test2.ksh script. i just can tell what it is. – user1015196 Jul 25 '13 at 20:07
  • typo in question....and that is the script that actually works. :) – user1015196 Jul 25 '13 at 20:29
  • Without the full test1 & test2 scripts, and the `ksh -x` output, I don't know if I can be much more help. Have you verfied that $VAR is the correct value when test2 executes? What is $RETURN_VALUE expected to capture? From the looks of things, you are setting the output of stored_proc2 to @rtnval, but I don't see where @rtnval will end up as RETURN_VALUE. – Michael Gardner Jul 25 '13 at 21:13
  • ok I have a little more information. In test2.ksh several lines before the isql is called I'm doing some file processing and so i've set the IFS: IFS=${DELIM} ..... ISQL_CMD..... this looks to be throwing it off. How do I disable or reset the IFS setting prior to calling isql? – user1015196 Jul 25 '13 at 23:38

1 Answers1

0

Ok I have figured this out after a full day of head scratching. test2.ksh is performing some file processing and setting the IFS value several lines prior to isql command. I had to reset or unset the IFS once I was done and isql command worked fine! the command to unset the IFS value is:

unset IFS

Thanks for those that were trying to help!!

user1015196
  • 503
  • 5
  • 18