Sponsored Content
Top Forums Shell Programming and Scripting Script works with bash 3.0 but not 3.2. Post 302299547 by forkandspoon on Friday 20th of March 2009 10:40:25 AM
Old 03-20-2009
Script works with bash 3.0 but not 3.2.

Hello,

So my knowledge of bash scripting is not that great and I have been trying to solve this problem on my own for awhile to no avail.



Here's the error I get when running it with an OS that uses bash 3.2.x:

testagain.sh: line 10: *-1: syntax error: operand expected (error token is "*-1")



Here's the script (sorry for the lack of indents not sure how the formatting on this forum works):

Code:
#!/bin/bash

cd /home/sites

for logdir in */logs; do
        
        for access_log in ${logdir}/access_log.*; do
              
                lognum=`echo $access_log | sed -e 's/.*access_log\.//'`;
                lognum=$(($lognum-1));
                mv $access_log ${logdir}/access_log-$(date -d"- $lognum  days" '+%Y%m%d');

        done

done


Last edited by fpmurphy; 03-20-2009 at 11:49 AM.. Reason: Added code blocks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

substring command works but only in BASH shell

I am having trouble running a .sh file. The code 'x=${file_name:0:$z-11}' is giving me a bad substitution error. However when I run in BASH it works. Thing is when this goes to production the .sh will not be running in BASH. Is there a way to substring a string not in BASH or a way to invoke... (2 Replies)
Discussion started by: edwardtk11
2 Replies

2. Shell Programming and Scripting

Works from bash prompt, but not from script!

I'm trying to use unison from bash on windows with cygwin. I don't know if this is a cygwin question, bash question or unison question. Since I always get reprimanded by the cygwin mailing list for assuming it is a cygwin problem, I'll assume it is a bash question. The following commands work... (7 Replies)
Discussion started by: siegfried
7 Replies

3. UNIX for Dummies Questions & Answers

Error: `mv olddir/ newdir/ ` never works on new version of bash?

Suppose you have a directory called "olddir" exists but no "newdir", you want to rename "olddir" to"newdir" In previous versions (at least in 2.05b.0) of bash, you can try mv olddir/ newdir/ OR mv olddir/ newdir But in new versions of bash, if you mv olddir/ newdir/ BASH panics: mv:... (5 Replies)
Discussion started by: meili100
5 Replies

4. UNIX for Dummies Questions & Answers

Bash script dont works when executed as cronjob

Hello, i have cronjob: crontab -l * * * * * pkill -f domexpcheck;sh /root/dom/domexpcheck.sh it runs: /var/log/cron Mar 25 12:11:01 vps crond: (root) CMD (pkill -f domexpcheck;sh /root/dom/domexpcheck.sh) but somehow script dont run properly via cronjob. But when i execute cronjob... (7 Replies)
Discussion started by: postcd
7 Replies

5. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies

6. Shell Programming and Scripting

Sourcing Env file with eval works with ksh but not BASH

Hi, I am running this on Redhat 5.10 I have a simple test script called test.sh which has the following contents and it uses the BASH shebang. ------------------------------------------------------------- #!/bin/bash eval `/tmp/filereader.pl /tmp/envfile.txt` echo "TESTPATH=$TESTPATH" ... (28 Replies)
Discussion started by: waavman
28 Replies

7. Shell Programming and Scripting

Script in bash that works only some of the time

I ran this script yesterday (in the background) /usr/bin/nohup myfilelocation/myscriptname.sh & the script worked perfectly. i ran it today (also in the background) and just sat there. So i killed it and ran it normally and it worked perfectly. Anyone suggest why it just sat there and... (8 Replies)
Discussion started by: twinion
8 Replies

8. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

9. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

10. UNIX for Beginners Questions & Answers

Command works interactively but not in bash script

The below command works in the terminal interactively but not as part of a bash script. I though maybe I needed to escape the "$dir" so it isn't interpreted literally, but that's not it. Thank you :). interactively in terminal dir=/path/to new=$(ls "$dir"/*.csv -tr | tail -n 1) && echo... (6 Replies)
Discussion started by: cmccabe
6 Replies
QSSIGN(1)							  qssign man page							 QSSIGN(1)

NAME
qssign - Utility to sign and verify the integrity of log data. SYNOPSIS
qssign -s|S <secret> [-e] [-v] DESCRIPTION
qssign is a log data integrity check tool. It reads log data from stdin (pipe) and writes the signed data to stdout. OPTIONS
-s <secret> Passphrase used to calculate signature. -S <program> Specifies a program which writes the passphrase to stdout. -e Writes end marker when stopping data signing. -v Verification mode checking the integrity of signed data. EXAMPLE
Sign: TransferLog "|./bin/qssign -s password -e |./bin/qsrotate -o /var/log/apache/access_log" Verify: cat access_log | qssign -s password -v SEE ALSO
qsexec(1), qsfilter2(1), qsgeo(1), qsgrep(1), qslog(1), qslogger(1), qspng(1), qsrotate(1), qstail(1) AUTHOR
Pascal Buchbinder, http://opensource.adnovum.ch/mod_qos/ mod_qos utilities 10.8 June 2012 QSSIGN(1)
All times are GMT -4. The time now is 01:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy