ksh vs ksh93 -- syntax error ... `(' unmatched.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh vs ksh93 -- syntax error ... `(' unmatched.
# 1  
Old 07-07-2010
ksh vs ksh93 -- syntax error ... `(' unmatched.

Code:
x=$(cat <<EOF
Hi.
EOF)

print "$x"

If my shebang is "/bin/ksh" this print "Hi." If my shebang is /bin/ksh93 this errors with:

syntax error at line 3: `(' unmatched.

I guess my default ksh is ksh88.

So, I'm used to setting variables this way, allowing a complex command (that may involving logging into a database, or whatever) to get its input from the here document and to return a single value directly into a variable. But, I also need ksh93-specific functionality.

Recommendations?
# 2  
Old 07-07-2010
My ksh93 outputs:
Code:
Hi.

# 3  
Old 07-07-2010
Maybe this is an AIX thing.
# 4  
Old 07-07-2010
try:
Code:
x=$(cat <<EOF
Hi.
EOF
)

This User Gave Thanks to vgersh99 For This Post:
# 5  
Old 07-07-2010
Quote:
Originally Posted by vgersh99
try:
Code:
x=$(cat <<EOF
Hi.
EOF
)

That did it, Thanks.

Under my Linux ksh93 the original code works, with the closing parenthesis right after the EOF, but under AIX ksh93 it fails. The here document terminator should always be on a line by itself, though, so your change is definitely a correction, not a workaround.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Ksh93 on Linux compatible with ksh93 on AIX

Hi Experts, I have several shell scripts that have been developed on a Linux box for korn ksh93. If we want to run this software on an AIX 6.1 box that runs ksh88 by default can we just change the she-bang line to reference /bin/ksh93 which ships with AIX as its "enhanced shell" to ensure... (6 Replies)
Discussion started by: Keith Turley
6 Replies

2. Shell Programming and Scripting

ksh Script - Syntax error `done' unexpected

Hello, I am working on my first ksh script to review daily reports. The script uses different functions to check different types of reports in csv format. A control file gets read in with information regarding the report, other info, and the function to use. When I run the script I get the... (4 Replies)
Discussion started by: bot9196
4 Replies

3. Shell Programming and Scripting

ksh Arithmetic syntax error while comparing decimal numbers

Hello, I am having a problem when i execute following script on RHEL 6.4. Same script works fine on another machine where I have same version of RHEL and KSH. Below is the rpm and RHEL version. ossvm12(0)> rpm -qa | grep ksh ksh-20100621-19.el6.x86_64 ossvm12(0)> cat... (7 Replies)
Discussion started by: Adithya Gokhale
7 Replies

4. Shell Programming and Scripting

Help with ksh syntax error Unexpected Fi

Issue resolved, thanks (6 Replies)
Discussion started by: dangell82
6 Replies

5. Shell Programming and Scripting

ksh: 0403-057 Syntax error: `done' is not expected.

Hi I am getting error 'ksh: 0403-057 Syntax error: `done' is not expected.' when running below script any one can provide inputs on this. ------------------------ if then echo "Report Name |Modification Date|Report File Size|Owner" >SOX_`date +'%Y%m%d'` while read line do... (2 Replies)
Discussion started by: karnatis
2 Replies

6. Shell Programming and Scripting

KSH syntax error

Hi all, Anyone know why I get the error below under ksh? $ EXCLUDES=( $(< "$EXCLUDES_FILE") ) sh: syntax error: `(' unexpected I'm trying to use the above line in a script and it's not working. The guy that gave me the script was running in a linux environment, so I'm thinking this might... (1 Reply)
Discussion started by: mmw
1 Replies

7. Shell Programming and Scripting

ksh syntax error: `(' unexpected

So I am trying to convert my bash script into ksh, and this is what I have in the file so far: #!/bin/ksh login() { if then sendcmd BETA else sendcmd "$(xxd -c 32 -g 0 ${ZETA_ZETA} | awk '{print $2}')" fi } But when I run it: $ ./test.sh ... (1 Reply)
Discussion started by: guitarscn
1 Replies

8. Shell Programming and Scripting

Receiving error: ./ang.ksh[35]: 0403-057 Syntax error at line 116 : `done' is not expected.

Hi All I am quite new to Unix. Following is a shell script that i have written and getting the subject mentioned error. #!/bin/ksh #------------------------------------------------------------------------- # File: ang_stdnld.ksh # # Desc: UNIX shell script to extract Store information.... (3 Replies)
Discussion started by: amitsinha
3 Replies

9. Shell Programming and Scripting

ksh-script "arithmetic syntax error" comparing strings

Hi all, Iīve already searched the forum but canīt find what i am doing wrong. I am trying to compare two variables using ksh under red hat. The error I get is: -ksh: .: MDA=`md5sum /tmp/ftp_dir_after_transfer | cut -d' ' -f1 ` MDB=`md5sum /tmp/ftp_dir_before_transfer | cut -d' ' -f1 `... (3 Replies)
Discussion started by: old_mike
3 Replies

10. Shell Programming and Scripting

Getting error "syntax error at line 78 : `<' unmatched"

Hi Guys, I have a following code in cm1.sh script. cnt=`sqlplus -s <un>/<pwd> << !EOF set heading off verify off pagesize 0 select count(*) from fnd_svc_components where component_name like '%Mailer%' and component_status != 'RUNNING'; exit; !EOF` echo $cnt if ; then sqlplus -s... (1 Reply)
Discussion started by: sshah1001
1 Replies
Login or Register to Ask a Question