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
EXICYCLOG(8)						      System Manager's Manual						      EXICYCLOG(8)

NAME
exicyclog - Cycle exim's logfiles SYNOPSIS
eximcyclog DESCRIPTION
The exicyclog script can be used to cycle (rotate) mainlog and rejectlog files. This is not necessary if only syslog is being used. Some operating systems have their own standard mechanisms for log cycling, and these can be used instead of exicyclog if preferred. Each time exicyclog is run the file names get 'shuffled down' by one. If the main log file name is mainlog (the default) then when exicy- clog is run mainlog becomes mainlog.01, the previous mainlog.01 becomes mainlog.02 and so on, up to a limit which is set in the script, and which defaults to 10. Reject logs are handled similarly. If no mainlog file exists, the script does nothing. Files that 'drop off' the end are deleted. All files with numbers greater than 01 are compressed, using a compression command which is configured by the COMPRESS_COMMAND setting in Local/Makefile. It is usual to run "exicy- clog" daily from a root "crontab" entry of the form 1 0 * * * su exim -c /usr/exim/bin/exicyclog assuming you have used the name 'exim' for the Exim user. You can run exicyclog as root if you wish, but there is no need. BUGS
This manual page needs a major re-work. If somebody knows better groff than us and has more experience in writing manual pages, any patches would be greatly appreciated. SEE ALSO
exim(8), /usr/share/doc/exim4-base/ AUTHOR
This manual page was stitched together from spec.txt by Andreas Metzler <ametzler at downhill.at.eu.org>, for the Debian GNU/Linux system (but may be used by others). March 26, 2003 EXICYCLOG(8)
All times are GMT -4. The time now is 12:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy