awk "Invalid char ' in expession" error


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
awk "Invalid char ' in expession" error

I have an HP PPM (ITG) application that is running an awk command in cygwin bash shell as part of ITG process moving SAP transports on a Windows 2003 server. The awk command checks the first two characters of a file containing return code that was retrieved from the SAP server. It is throwing the error "invalid character ' in expression" . The following is the log:

sent command:
bash-2.05$ cat imp_619015_5.txt; echo KSC_EXIT_STATUS $?
received echo:
cat imp_619015_5.txt; echo KSC_EXIT_STATUS $?
00#!#Successful, Return Code: 00
KSC_EXIT_STATUS 0

sent command:
bash-2.05$ returncode=`cat imp_619015_5.txt | awk '{printf substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
received echo:
returncode=`cat imp_619015_5.txt | awk '{printf substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
awk: cmd. line:1: {printf substr($1,1,2)}
awk: cmd. line:1: ^ Invalid char ' in expression
KSC_EXIT_STATUS 2
Command: [returncode=`cat imp_619015_5.txt | awk '{printf substr($1,1,2)}'`] did not complete successfully.
Aborting command execution.
Closing telnet session.
Errors occurred during command execution.

When I run the awk command in the command line in the bash shell on the server and echo the returncode variable, it returns "00" as expected. Not sure why it is failing in ITG. Rebooting the server seems to solve the problem temporaraly but the problem comes back after a few days. Anyone have another way to run this command that I could try? Any ideas what could be causing the error? I do not have much experience in unix scripting.
# 2  
The syntax of the printf statement isn't proper, it should looks like:

Code:
awk '{printf("%s", substr($1,1,2))}'

or use the print statement instead of printf:

Code:
awk '{print substr($1,1,2)}'

Regards
# 3  
Thanks Franklin52 for your reply. I tried both but still get the error:

bash-2.05$ returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
received echo:
returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
awk: cmd. line:1: {print substr($1,1,2)}
awk: cmd. line:1: ^ Invalid char ' in expression
KSC_EXIT_STATUS 2
Command: [returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`] did not complete successfully.
Aborting command execution.
Closing telnet session.
Errors occurred during command execution.

I wonder if there is something corrupt with the bash or cygwin on the server?

Thanks,
accsam1
# 4  
Try to replace this line:

Code:
returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?

with:

Code:
returncode=`cut -c1,2 imp_619015_5.txt`; echo KSC_EXIT_STATUS $?

Regards
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Computers
Difficulty: Easy
"HTML" stands for Hypertext Markup Language.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move a line containg "char" above line containing "xchar"

Okay, so I have a rather large text file and will have to process many more and this will save me hours of work. I'm not very good at scripting, so bear with me please. Working on Linux RHEL I've been able to filter and edit and clean up using sed, but I have a problem with moving lines. ... (9 Replies)
Discussion started by: rex007can
9 Replies

2. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

3. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

4. Shell Programming and Scripting

Perl "Invalid argument error"

Hi , we have a issue in server, we are running a perl script to connect our clients, but we are not able to connect, every time we are getting the "Invalid argument error" Even i checked all the necessary perl modules are i installed in this server, #create the listen socket my... (2 Replies)
Discussion started by: anishkumarv
2 Replies

5. UNIX for Advanced & Expert Users

Trace "free(): invalid next size (normal)" error on arm-linux board

Hi guys, i'm running a program on samsumg 6410 arm cpu board. it caused an "free(): invalid next size (normal)" fail. i try to use gdb for remote debugging: 1, start gdb server on board: gdbserver 192.168.1.20:1234 ./HostAP Process ./HostAP created; pid = 499 Listening on port... (8 Replies)
Discussion started by: ss1969
8 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. Solaris

significance of "+" char in SunOS "ls -l" output

Hi, I've noticed that the permissions output from "ls -l" under SunOS differs from Linux in that after the "rwxrwxrwx" field, there is an additional "+" character that may or may not be there. What is the significance of this character? Thanks, Suan (6 Replies)
Discussion started by: sayeo
6 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

10. Programming

error "Invalid argument" returned after call sched_setscheduler

the code is below and the was run on Solaris 9. ----------------------------- struct sched_param param; param.sched_priority = 99; if(sched_setscheduler(0, SCHED_RR, &param) == -1) { perror("setting priority"); exit(1); } ------------------------------- after the... (1 Reply)
Discussion started by: robin.zhu
1 Replies

Featured Tech Videos