I am getting an infinite loop from a script in Linux.
Here is the last version of the script in question. As you can see I tried to define everything properly:
The problem is simple: I want to loop over a series of dates: start_date and end_date.
I wanted to make it "nice" and intuitive and include the end_date in the calculations. If we remove the line:
then the scripts works fine - it just obviously stops at a date before the end_date.
Problem is: If I remove the line that increments the end_date then all is well and the script loops till end_date MINUS one day (obviously). By leaving the line there the scripts loops infinitely ! The current_date does increase but the loop's condition is never executed.
I sense that since the variable values do not affect the condition ( == ), then it probably has something to do with the variable type ???
I also tested with the variables not defined as integers but as strings.
IMPORTANT: The script works and I am not asking for an alternative way (would be nice to see a different approach but it's not necessary).
So, if you have any suggestions I want to understand what i am doing wrong with the *current* script and not a different way of doing this!
Thanks!
PS: I am a newbie but the fact that there are a few ways to define the same things in Korn , Bourne etc, begins to annoy me. I want to learn the proper syntax but it's difficult looking at other peoples code at work and on the net. Script synax and various shells seem to be permissive which makes me pick-up "bad habits" ...
---------- Post updated at 11:53 AM ---------- Previous update was at 10:57 AM ----------
Never mind !... I feel embarrassed.
I simplified the listeing here but in real life I had a second fixed nested llop. Inside that loop i was incrementing the date so it would basically "skip" an increement and the == would never apply.
Here is my script
LOGDATE=`date '+%Y-%m-%d %k:%M' | cut -c1-15`
echo $LOGDATE
echo "grep '$LOGDATE' /tmp/logs/vel.log >10min_log"
grep '$LOGDATE' /tmp/logs/vel.log>10min_log
grep '$LOGDATE' /tmp/logs/vel.logHere is the output of the script
-rw-r--r-- 1 wluser wluser 0 May 3... (7 Replies)
Linux. Bash 4.2.10.
Let's say that i want the stderr of a command redirected to one file (err), and both stdout and stderr redirected to another file (outanderr).
Easy. Many ways to do it. But may times the file outanderr will be messed up (with the output and the error mixed toghether).
... (3 Replies)
I am little bit confused by the behaviour of rm in Ubuntu.
It seems that as a regular user I can delete files owned by another user even when the permissions are set to 644.
Here is an example:
cjohnson@carbon:~/test$ sudo touch testfile
cjohnson@carbon:~/test$ ls -al
total 8
drwxr-xr-x... (2 Replies)
I have these two files in current dir:
oos.txt
oos_(copy).txt
I execute this find command:find . -regex './oos*.txt'And this outputs only the first file (oos.txt)! :confused:
Only if I add another asterisk to the find find . -regex './oos*.*txt' do I also get the second file... (7 Replies)
Hi people,
I'm having some strange behaviour with an 'expect' script.
spawn csession blah
expect "Username: "
send "userblah\r"
expect "Password: "
send "passwordblah\r"
interact
When I execute the script as root it runs perfectly.
However, when executed as any other... (0 Replies)
I've written a small script to replace certain words in all the the files in a directory.
#!/bin/sh
#Get list of files to be edited
file_list=`ls -p`
for i in $file_list
do
echo "Processing $i"
alteredi=`echo "$i" | sed -e 's/\//d/'`
if
then
if
then
#actual altering (2 Replies)
Apologies if this has been mentioned elsewhere, my search skills may be lacking somewhat today.
I have a script that does the following (as a test):
find . -name "*.txt" -exec file {} \; >>$sFullFilePath
Now, the variable is set up up correctly in the script too. When I run the script... (1 Reply)
So I have this script titled "testing.sh"
#!/bin/ksh
#PROGRAM INITIALIZATION
HomeDir=/home/sap/gl/ftp
server=testftp01
userid=ftp_uatollmsgbus
password="f&p53715"
MSGLOG=${HomeDir}/msglog.txt
FTPLogTmp=${HomeDir}/testing.tmp
FTPLogFile=${HomeDir}/testing.log... (1 Reply)
Hi gurus.
I implemented sudo and have the following in my sudo config file
***************
# User alias specification
User_Alias VENDOR = user1
# User privilege specification
VENDOR ALL = NOPASSWD: /bin/, /sbin/, /usr/local/bin/, \
!/bin/su,... (1 Reply)
I need a script to do the following and have no idea how to do it...can someone help?
I need to start Sql*Plus, load a query, say "unmatched.sql", run the query, then load unmatched.sc and run it, then print the output file that unmatched.sc created...
any help greatly appreciated.
Duckman (2 Replies)