Sponsored Content
Full Discussion: Error when executing script
Operating Systems Linux Red Hat Error when executing script Post 303001629 by anaigini45 on Wednesday 9th of August 2017 06:24:47 AM
Old 08-09-2017
Thank you so much for all the comments and suggestions.

I have now managed to compile the whole script, but still needs a bit more tweaking as there are few more errors.

Part of my script does this :

Code:
new=1
for f in `find . -name '*.filtered' | sort -r`; do                                                                  
> eximstats -nr "$f" > "eximstats_day"$new"_"$eximBC01.txt";
> eximstats -xls -nr  "$f" > "eximstats_day"$new"_"BC01.xls";
> ((new++));
> done

This returns errors like this :

Code:
bash: eximstats_day1_01082017.txt;
eximstats -xls -nr  ./mainlog.7.filtered > eximstats_day1_BC01.xls: No such file or directory
bash: eximstats_day2_01082017.txt;
eximstats -xls -nr  ./mainlog.6.filtered > eximstats_day2_BC01.xls: No such file or directory
bash: eximstats_day3_01082017.txt;
eximstats -xls -nr  ./mainlog.5.filtered > eximstats_day3_BC01.xls: No such file or directory
bash: eximstats_day4_01082017.txt;
eximstats -xls -nr  ./mainlog.4.filtered > eximstats_day4_BC01.xls: No such file or directory
bash: eximstats_day5_01082017.txt;
eximstats -xls -nr  ./mainlog.3.filtered > eximstats_day5_BC01.xls: No such file or directory
bash: eximstats_day6_01082017.txt;
eximstats -xls -nr  ./mainlog.2.filtered > eximstats_day6_BC01.xls: No such file or directory

However, when I execute the code directly on the terminal, there is no error (without the for loop) :

Code:
# eximstats -nr  mainlog.7.filtered > eximstats_day1_01082017.txt
# eximstats -xls -nr  mainlog.7.filtered > eximstats_day1_01082017.xls

Is there something wrong with the syntax?

---------- Post updated 08-09-17 at 06:24 PM ---------- Previous update was 08-08-17 at 07:19 PM ----------

I found out that the error was variable substitution. I corrected the code like this, and it worked properly :

Code:
new=1
for f in `find . -name '*.filtered' | sort -r`; do
       eximstats -nr "$f" > eximstats_day"$new"_"$eximBC07".txt;
       eximstats -xls -nr  "$f" > eximstats_day"$new"_"$eximBC07".xls;
       ((new++));
done

However, I have another part of the script that has this line :

Code:
eximstats -merge eximstats_day*.txt > "eximstats.consolidated_$MONTH$YEAR.txt"

I did not put the "" for the $MONTH$YEAR, but it still produced the output I wanted. Why is this?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

error while executing the script

Hello I am executing the following script nawk 'NR == 1 || substr($0,63,5) ~ /H... / && \ _++ == 2 { fn && close(fn); fn = "part_" ++c; _ = 1 } { print > fn }' sample.dat When i execute as it is it is executing fine. but when i execute the whole script as a single line like below ... (2 Replies)
Discussion started by: dsdev_123
2 Replies

2. Shell Programming and Scripting

Error while executing a script

My script is as below : #!/bin/sh for line in `cat Results.txt` do FEILD1=`echo $line |awk -F"|" '{print $1}'` FEILD2=`echo $line |awk -F"|" '{print $2}'` FEILD3=`echo $line |awk -F"|" '{print $3}'` FEILD4=`echo $line |awk -F"|" '{print $4}'` echo "$FEILD1 $FIELD2 $FIELD3 $FIELD4" done ... (15 Replies)
Discussion started by: shwetainnani
15 Replies

3. Shell Programming and Scripting

Error while executing the below script

I am executing the below in telnet #!/usr/bin/ksh File1=simple.txt # The file to check LogFile=simple.log # The log file DelayMax=30 # Timeout delay Tolerance=2 # BEGIN ############################## while true do StampNow=$(date +%s)/60 # stamp in minutes ... (3 Replies)
Discussion started by: chinniforu2003
3 Replies

4. UNIX for Dummies Questions & Answers

Error Executing the script.

Hi , I m getting an error after executing the script. My script. Script is used to find out the date on 8 different machines(mentioned in SERVERNAMES file). I have added public key to avoid ssh password and ssh without password working fine. #!/bin/sh fn_VMFind() { Date=`ssh -t... (5 Replies)
Discussion started by: pinga123
5 Replies

5. Shell Programming and Scripting

Error while executing a script

Hi Please assist. Im getting an error while execuing the script name d "cdsnd.basel.cd_new " as siiadm user. Thanks. siiadm> ls -l total 64 -rwxr-xr-x 1 siiadm sboadm 1004 Sep 17 2008 cdsnd.basel.cd -rwxr-xr-x 1 siiadm sapsys 998 Nov 16 09:14 cdsnd.basel.cd_new... (1 Reply)
Discussion started by: samsungsamsung
1 Replies

6. Shell Programming and Scripting

getting the error 'not found' while executing the script

Hi, I am not able to figure out what the problem is: getting the following error sqltst.sh: 1: not found here is the script #!/bin/sh . /home/dev1/.profile . /home/dev1/.infenv `sqlplus -s $REPDB_LOGON << EOF SET SERVEROUT ON SET FEEDBACK OFF SET HEADING OFF SET TRIMSPOOL... (4 Replies)
Discussion started by: svajhala
4 Replies

7. Shell Programming and Scripting

Error executing script

Please delete de thread. Thanks. (10 Replies)
Discussion started by: Rodrih92
10 Replies

8. Linux

Libssh2 error while executing script

hi all, i am getting libssh2 error while executing script in RHEL 6, when i locate that file its not there below is the ouput of this # locate libssh2_agent_init # cat /etc/issue Red Hat Enterprise Linux Server release 6.1 (Santiago) Kernel \r on an \m how do i resolve this issue, i... (1 Reply)
Discussion started by: muzaffar.k
1 Replies

9. UNIX for Dummies Questions & Answers

Error executing the script

I have the following script test.sh owned by dwdev account and group dwdev, the permissions on the script are as follows. -rw-r-x--- 1 dwdev dwdev 279 Sep 17 13:19 test.sh Groups: cat /etc/group | grep dwdev dwdev:x:704:dwdev dwgroup:x:725:dwdev writers:x:726:dwdev User: cat /etc/passwd |... (3 Replies)
Discussion started by: Ariean
3 Replies

10. Shell Programming and Scripting

Gettting error while executing script

getting error as below while executing script in linux. OS version: Linux VGP-3GPSDB-LX 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux ./imxtract.sh: line 395: unexpected EOF while looking for matching ``' ./imxtract.sh: line 402: syntax error:... (1 Reply)
Discussion started by: Riverstone
1 Replies
EXIMSTATS(8)							       EXIM4							      EXIMSTATS(8)

NAME
eximstats - generates statistics from Exim mainlog or syslog files. SYNOPSIS
eximstats [Output] [Options] mainlog1 mainlog2 ... eximstats -merge [Options] report.1.txt report.2.txt ... > weekly_report.txt Output: -txt Output the results in plain text to STDOUT. -txt=filename Output the results in plain text. Filename '-' for STDOUT is accepted. -html Output the results in HTML to STDOUT. -html=filename Output the results in HTML. Filename '-' for STDOUT is accepted. -xls Output the results in Excel compatible Format to STDOUT. Requires the Spreadsheet::WriteExcel CPAN module. -xls=filename Output the results in Excel compatible format. Filename '-' for STDOUT is accepted. Options: -hnumber histogram divisions per hour. The default is 1, and 0 suppresses histograms. Valid values are: 0, 1, 2, 3, 5, 10, 15, 20, 30 or 60. -ne Don't display error information. -nr Don't display relaying information. -nr/pattern/ Don't display relaying information that matches. -nt Don't display transport information. -nt/pattern/ Don't display transport information that matches -qlist List of times for queuing information single 0 item suppresses. -tnumber Display top <number> sources/destinations default is 50, 0 suppresses top listing. -tnl Omit local sources/destinations in top listing. -t_remote_users Include remote users in the top source/destination listings. -include_original_destination Include the original destination email addresses rather than just using the final ones. Useful for finding out which of your mailing lists are receiving mail. -show_dtlist Show the delivery times (DT)for all the messages. Exim must have been configured to use the +deliver_time logging option for this option to work. list is an optional list of times. Eg -show_dt1,2,4,8 will show the number of messages with delivery times under 1 second, 2 seconds, 4 seconds, 8 seconds, and over 8 seconds. -show_rtlist Show the receipt times for all the messages. The receipt time is defined as the Completed hh:mm:ss - queue_time_overall - the Receipt hh:mm:ss. These figures will be skewed by pipelined messages so might not be that useful. Exim must have been configured to use the +queue_time_overall logging option for this option to work. list is an optional list of times. Eg -show_rt1,2,4,8 will show the number of messages with receipt times under 1 second, 2 seconds, 4 seconds, 8 seconds, and over 8 seconds. -byhost Show results by sending host. This may be combined with -bydomain and/or -byemail and/or -byedomain. If none of these options are specified, then -byhost is assumed as a default. -bydomain Show results by sending domain. May be combined with -byhost and/or -byemail and/or -byedomain. -byemail Show results by sender's email address. May be combined with -byhost and/or -bydomain and/or -byedomain. -byemaildomain or -byedomain Show results by sender's email domain. May be combined with -byhost and/or -bydomain and/or -byemail. -pattern Description /Pattern/ Look for the specified pattern and count the number of lines in which it appears. This option can be specified multiple times. Eg: -pattern 'Refused connections' '/refused connection/' -merge This option allows eximstats to merge old eximstat reports together. Eg: eximstats mainlog.sun > report.sun.txt eximstats mainlog.mon > report.mon.txt eximstats mainlog.tue > report.tue.txt eximstats mainlog.wed > report.web.txt eximstats mainlog.thu > report.thu.txt eximstats mainlog.fri > report.fri.txt eximstats mainlog.sat > report.sat.txt eximstats -merge report.*.txt > weekly_report.txt eximstats -merge -html report.*.txt > weekly_report.html o You can merge text or html reports and output the results as text or html. o You can use all the normal eximstat output options, but only data included in the original reports can be shown! o When merging reports, some loss of accuracy may occur in the top n lists. This will be towards the ends of the lists. o The order of items in the top n lists may vary when the data volumes round to the same value. -charts Create graphical charts to be displayed in HTML output. Only valid in combination with -html. This requires the following modules which can be obtained from http://www.cpan.org/modules/01modules.index.html GD GDTextUtil GDGraph To install these, download and unpack them, then use the normal perl installation procedure: perl Makefile.PL make make test make install On Debian GNU/Linux you can use "apt-get install libgd-perl libgd-text-perl libgd-graph-perl" instead. -chartdirI <dir> Create the charts in the directory <dir> -chartrelI <dir> Specify the relative directory for the "img src=" tags from where to include the charts -emptyok Specify that it's OK to not find any valid log lines. Without this we will output an error message if we don't find any. -d Debug flag. This outputs the eval()'d parser onto STDOUT which makes it easier to trap errors in the eval section. Remember to add 1 to the line numbers to allow for the title! DESCRIPTION
Eximstats parses exim mainlog and syslog files to output a statistical analysis of the messages processed. By default, a text analysis is generated, but you can request other output formats using flags. See the help (-help) to learn about how to create charts from the tables. AUTHOR
There is a web site at http://www.exim.org TO DO
This program does not perfectly handle messages whose received and delivered log lines are in different files, which can happen when you have multiple mail servers and a message cannot be immediately delivered. Fixing this could be tricky... Merging of xls files is not (yet) possible. Be free to implement :) perl v5.14.2 2014-07-24 EXIMSTATS(8)
All times are GMT -4. The time now is 04:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy