nawk syntax error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting nawk syntax error
# 1  
Old 10-13-2008
nawk syntax error

I have following problem! If i trie to execute this command:

nawk '{system("/opt/EMCpower/bin/emcpadm renamepseudo -f d -s "$1" -t "$2")}' ${filestart}$1${fileend}

where ${filestart}$1${fileend} is a filename and $1 and $2 is the first and second column of the file! I get the following error message if i execute it in my script:

nawk: syntax error at source line 1
context is
{system("/opt/EMCpower/bin/emcpadm renamepseudo -f d -s "$1" -t >>> "$2")} <<<
nawk: illegal statement at source line 1
missing }
missing )

can someone help me?
# 2  
Old 10-13-2008
You have unbalanced quotes, try:

Code:
nawk '{system("/opt/EMCpower/bin/emcpadm renamepseudo -f d -s "$1" -t "$2)}' ...

# 3  
Old 10-13-2008
thanks -> this works!
# 4  
Old 10-13-2008
nawk '{system("/opt/EMCpower/bin/emcpadm renamepseudo -f d -s "$1" -t "$2)}' ...

if i want to check if $1 and $2 starts with the letters emcpower and just want to execute the command if it is so - how can i fulfil this?
# 5  
Old 10-13-2008
Code:
awk '$1 ~ /^emcpower/ && $2 ~ /^emcpower/{...}'

Regards
# 6  
Old 10-14-2008
the command makes problems -> it says: ssh: syntax error at line 1: `emcpower/{system' unexpected

ssh remotemaschine nawk '$1 ~ /^emcpower/ && $2 ~ /^emcpower/{system("...")}' file

any other ideas?

Last edited by Helmut; 10-14-2008 at 05:30 AM..
# 7  
Old 10-14-2008
ok - the problem is that i have to copy my file to the remote destination!

how can i execute the following command on my remote host?

this command is correct:

nawk '{system("/opt/EMCpower/bin/emcpadm renamepseudo -f d -s "$1" -t "$2)}' filename

but how can i do this remote? my problem is that after ssh $1 I canīt make "(....)" because there are " in my command! so any ideas?

scp ${filestart}$1${fileend} $1:${destdir}
ssh $1 (cd ${destdir} && nawk '{system("/opt/EMCpower/bin/emcpadm renamepseudo -f d -s "$1" -t "$2)}' ${filestart}$1${fileend} && rm ${filestart}$1${fileend})

the solution is to give the nawk command in a file, copy this file to the remote server and execute it there!

Last edited by Helmut; 10-14-2008 at 10:27 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

Hello, I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time. My script: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if ; then echo "There is no errors in the logs" fi And after... (10 Replies)
Discussion started by: jedzio
10 Replies

2. Shell Programming and Scripting

Nawk Problem - nawk out of space in tostring on

Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
Discussion started by: Abhiraj Singh
12 Replies

3. Shell Programming and Scripting

Error running nawk script

Hi, I was trying to use nawk script given in this link https://www.unix.com/aix/19979-df-output-not-aligned.html but when i do this im getting this error $ df -k|formatDF.nawk -ksh: formatDF.nawk: not found Can anyone help me on this... (6 Replies)
Discussion started by: niteesh_!7
6 Replies

4. Shell Programming and Scripting

Nawk in a tail - syntax question

Hello. I run the following command to get data from a logfile: nawk 'BEGIN {FS="|"} {if ($6=="sonusSgxConfigurationErrorNotification") print ":" $10 ":" $11}' sonustrap.log | nawk 'BEGIN {FS=":"} {print $3 $5}' This command is 'static' from the .log file, however I wanted tail -f this and... (3 Replies)
Discussion started by: lennys26
3 Replies

5. 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

6. UNIX for Dummies Questions & Answers

nawk: syntax error at source line 11

Hi, I executing a awk in a shell script. A part of AWK is: nawk -F"Ī" -v fichero=${DIRECTORIO_PARAMETROS}/${FICHERO_CONFIGURACION_CHEQUEOS} -v sistema=${SISTEMA_SEDRA} -v fichero_no_validos="No_validos_CAMPO_TIPO_${SIST}.dat" 'BEGIN{ if ( fichero != "") { ... (4 Replies)
Discussion started by: pepeli30
4 Replies

7. AIX

nim mksysb error :/usr/bin/savevg[33]: 1016,07: syntax error

-------------------------------------------------------------------------------- Hello, help me please. I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? : Command : failed stdout: yes stderr: no... (9 Replies)
Discussion started by: astjen
9 Replies

8. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

9. Shell Programming and Scripting

nawk empty regular expression error

Hello, All. please help me with this problem. i need to use variable as regular expression. some thing like this: BEGIN { RS="\n"; ORS="\n"; reg_exp = ".+Dec.+"; # i mean that regular expression is any symbol before "Dec" and any symbol after it. For example <Worksheet... (6 Replies)
Discussion started by: Rjkz
6 Replies
Login or Register to Ask a Question