Solaris script using awk giving errors - please advise


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solaris script using awk giving errors - please advise
# 1  
Old 09-25-2012
Solaris script using awk giving errors - please advise

I'm using solaris 10

Scenario as follows

I have a logfile with 2 columns:
column 1 = source directory + filename
column 2 = destination directory + filename

Using cron, my script polls for new files and adds them to the logfile ($ELOG) as described above. Using sed, the distination directory is created by changing 1 one the sub-directory locations

I'm trying to use awk to parse the file:
- encrypt the file
- copies the file to the destination folder

...
...
Code:
cat $ELOG | while read line;
do
   echo $line | awk '{print "ENCRYPT "$1" " print "<password>"}' | sh
   echo $line | awk '{print "cp "$1" "$2}' | sh

done

(ENCRYPT is a 3rd party executable file)

When I run the shell script, I get the following errors:
Code:
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1

__________________

Can you help advise where/what I am doing wrong. Equally, if there is a smarter way of completig this task, that would be great too

Thanks in advance

David

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.
# 2  
Old 09-25-2012
You are missing a semicolon before the second print statement.
# 3  
Old 09-25-2012
use 'nawk' on Solaris...
Code:
nawk '{print "ENCRYPT", $1 ORS "<password>" ORS "cp",$1, $2}' "${ELOG}" | sh

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting from Linux bash (GNU) to Solaris script syntax errors

Original script written on CentOS 6.3 with GNU bash 4.1.2 Destination system is Solaris 9 with GNU bash 2.05 (not changeable by me) I have a script written on the linux side but now we need to provide a version to another site that "doesn't like linux". I've been going through changing the ] or... (13 Replies)
Discussion started by: oly_r
13 Replies

2. Shell Programming and Scripting

awk & basename puzzler - advise sought

Hi I have been able generate a file ($ELOG) that can have multiple lines within it. The first column represents the full path source file and the other is the full path target ... the file names are the same but the target directory paths are slightly different. <source_dir1>/file1 ... (4 Replies)
Discussion started by: davidra
4 Replies

3. Solaris

Need advise on setting up solaris 10 2 nodes cluster

I am new to setting up sun solaris 10 cluster, I have 2 sun sparc t3-1 servers (identical), going to use them as web servers (sun one java web server 7), looking for data replication and real time fail over. My question is do I need external storage to configure the cluster? or I can just use... (3 Replies)
Discussion started by: spitfire2011
3 Replies

4. Shell Programming and Scripting

Script working in AIX, but giving error in SOLARIS

Hi, My script is working fine in AIX but throwing an error in SOLARIS system. Here is the error message that I am getting when calculating the elapsed time: /home/x772525/FindETA.sh: start_mins = *60 + : syntax error . ((start_mins = $(expr substr "$j" 1 2)*60 + $(expr substr "$j" 4... (6 Replies)
Discussion started by: ajayakunuri
6 Replies

5. Red Hat

Linux system hangs giving ntp errors

Hi folks, I am facing issue of my system (host1) getting hanged after throwing following ntpd messages. I am not able to ssh to the server there after. only option is to restart the host: Dec 29 02:58:51 host1 ntpd: time reset -0.207907 s Dec 29 02:58:51 host1 ntpd: synchronisation lost Dec 29... (0 Replies)
Discussion started by: SiddhV
0 Replies

6. BSD

dmesg giving errors

When running dmesg, the output is a long list of the following: ACPI Error: No object attached to node 0xffffff00016622e0 20090521 exresnte-211 ACPI Error (uteval-0329): Method execution failed (Node 0xffffff00016622e0), AE_AML_NO_OPERAND As a workaround I resort to sysctl, which gives... (0 Replies)
Discussion started by: figaro
0 Replies

7. Shell Programming and Scripting

Need advise to process the file with awk

Hi gurus, i need your advise on how to process this file using awk. i have this file COLA COLB COLC COLD COLE COLF COLG COLH AAAA 86 111 122 133 144 155 266 377 BBBB 70 211 222 233 244 255 266 ... (6 Replies)
Discussion started by: ablanc
6 Replies

8. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

awk script giving unstable results

Hi all Here I came accross a situation which i am unable to reason out... snippet 1 psg ServTest | grep -v "grep" | grep -v "vi" | awk '{ pgm_name=$8 cmd_name="ServTest" gsub(/]*/,"",pgm_name) if(pgm_name==cmd_name) { print "ServTest Present =" cmd_name} }'... (10 Replies)
Discussion started by: Anteus
10 Replies

10. Programming

gcc Compiler Switches: giving Illogical Errors

Hi, Has anyone used gcc compiler and know alot about it? I am compiling a file with: gcc -o xyz xyz.c abc.o -lsocket -lnsl it compiles pretty fine. But whe I use switches gcc -o -Wall -pedantic -ansi xyz xyz.c abc.o -lsocket -lnsl it starts giving illogical, rather I should say stupid... (1 Reply)
Discussion started by: Ahsan
1 Replies
Login or Register to Ask a Question