问题描述:

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.

网友答案:

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!!

相关阅读:
Top