cron does not evaluate the quotes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cron does not evaluate the quotes
# 1  
Old 04-20-2010
cron does not evaluate the quotes

Hi all,

I have a script that runs perfectly from cmd, but in the cron it gives a strange ':::::::::::::::' output instead of evaluating the part inside the quotes.
this is the script:
Code:
bash-3.00# more test 
#!/bin/ksh
#-----swap---
TEMP_FILE=/HealthCheck/test/file.txt
swap -s | tee $TEMP_FILE
echo "Swap is:\n`more $TEMP_FILE` "
#------------
bash-3.00#

but the output when its run from cron is:

Code:
bash-3.00# more log.log 
total: 3079208k bytes allocated + 142136k reserved = 3221344k used, 4112000k available
Swap is:
::::::::::::::
/HealthCheck/test/file.txt
::::::::::::::
total: 3079208k bytes allocated + 142136k reserved = 3221344k used, 4112000k available 
bash-3.00#

the correct output from cmd is:
Code:
bash-3.00# ./test 
total: 3079136k bytes allocated + 142168k reserved = 3221304k used, 4112048k available
Swap is:
total: 3079136k bytes allocated + 142168k reserved = 3221304k used, 4112048k available 
bash-3.00#


any ideas from anyone? its part of a much bigger script and i will have to make the changes like 100 times to fix the whole script. Does anyone know a magical line i can add to fix it instead?

Thanks.

Last edited by pludi; 04-20-2010 at 11:53 AM.. Reason: code tags, please...
# 2  
Old 04-20-2010
Your cron may be executing with a different shell than you expect. As the first line of your cron, try
Code:
SHELL=/bin/bash

or
Code:
SHELL=/bin/ksh

etc.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace Double quotes within double quotes in a column with space while loading a CSV file

Hi All, I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes. Sample Data : "221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies

2. Shell Programming and Scripting

Issue with Single Quotes and Double Quotes for prompt PS1

Hi, Trying to change the prompt. I have the following code. export PS1=' <${USER}@`hostname -s`>$ ' The hostname is not displayed <abc@`hostname -s`>$ uname -a AIX xyz 1 6 00F736154C00 <adcwl4h@`hostname -s`>$ If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies

3. UNIX for Dummies Questions & Answers

How does ||: evaluate?

In BASH, how does ||: get interpreted. I know || is logical or. And I believe : evaluates to true. Can someone give a thorough explanation for this usage? Example for i in $IGGY do && skipdb=1 || : (6 Replies)
Discussion started by: glev2005
6 Replies

4. Shell Programming and Scripting

How to evaluate the value of a variable ?

How to evaluate the value of a variable ? For example: a=var $a=value !!!error happens!!! I want to evaluate var=value, how to realize it? Thanks! ---------- Post updated at 03:37 AM ---------- Previous update was at 02:22 AM ---------- I am using linux bash. a=var $a=value... (4 Replies)
Discussion started by: 915086731
4 Replies

5. Shell Programming and Scripting

Having a terrible problem with quotes/single quotes!

Hello. I'm trying to write a bash script that uses GNU screen and have hit a brick wall that has cost me many hours... (I'm sure it has something to do with quoting/globbing, which is why I post it here) I can make a script that does the following just fine: test.sh: #!/bin/bash # make... (2 Replies)
Discussion started by: jondecker76
2 Replies

6. UNIX for Dummies Questions & Answers

grep single quotes or double quotes

Unix superusers, I am new to unix but would like to learn more about grep. I am very familiar with regular expressions as i have used them for searching text files in windows based text editors. Since I am not very familiar with Unix, I dont understand when one should use GREP with the... (2 Replies)
Discussion started by: george_vandelet
2 Replies

7. Shell Programming and Scripting

Single quotes and double quotes

Hi guys, I have a sed line in double quotes which works fine, but I want it to be in single quotes here is the sed line sed "/abc_def/s/\'.*\'/\'\${abc_def}\'/" can some one give the equivalent to the above script in single quotes Thanks a ton (5 Replies)
Discussion started by: sol_nov
5 Replies

8. Shell Programming and Scripting

Evaluate the value of a variable?

I have variables: FOO="Text" BAR="FOO" I'd like to be able to evaluate the variable named as the value of $BAR. echo $FOO Text echo $BAR FOO This is what I'd like to do: echo ${$BAR} (this won't work) Text (3 Replies)
Discussion started by: Ilja
3 Replies

9. Shell Programming and Scripting

Double quotes or single quotes when using ssh?

I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example, $ ITSME=itsme $ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME" itsme $ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME' itsyou $... (3 Replies)
Discussion started by: password636
3 Replies

10. Shell Programming and Scripting

how to get variable to re-evaluate itself?

Probably a simple one. Basically I am retrieving a number from a file - setting a variable against it and then incrementing this by 1 and using this as an entry number in a log file for messages. I need the variable to re-evalute itself each time I call it so I get the latest number in the file -... (1 Reply)
Discussion started by: frustrated1
1 Replies
Login or Register to Ask a Question