LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2006, 04:54 AM   #1
bio_informatics
LQ Newbie
 
Registered: May 2006
Posts: 5

Rep: Reputation: 0
crontab is ok, but problem in code


Hi everybody

I have a script test.sh which is excuted every 15 minutues,

#!/bin/bash
ls /home/user1
I resieve email evrey 15 minutes with the content of output of ls command

the problem when i add this command to the script.
myvar="some text"
echo "$myvar " >> my.txt

my.txt file doesn't change at all, in another words, the content of $myvar doesn't dump to my.txt file.

and if I changed it to
echo "$myvar"
it dumps the content to the email.

can you help me in this, i want the content of the script file which is run by crontab to dump the contents to the file.
 
Old 12-11-2006, 05:19 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,593

Rep: Reputation: 123Reputation: 123
Are you sure you have read/write-access? I don't know where cron tries to create that file "my.txt". Maybe try to give a path in your home folder like "/home/user/my.txt" instead?
 
Old 12-11-2006, 05:20 AM   #3
gani
Member
 
Registered: Jun 2004
Location: Metro Manila, Philippines
Distribution: OpenBSD, Slackware, XP
Posts: 347

Rep: Reputation: 31
Quote:
the problem when i add this command to the script.
myvar="some text"
echo "$myvar " >> my.txt

my.txt file doesn't change at all, in another words, the content of $myvar doesn't dump to my.txt file.
It should be 'echo $myvar >> my.txt'. Don't enclose the variable within " ".

---------
GANI
 
Old 12-11-2006, 06:04 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
@gani: the double quotes are just fine. The second remark of the OP that 'echo "$myvar"' dumps to mail just fine, proves this point.

@bio_informatics: I too suspect a problem with the path to the file. Make sure it's an absolute path, not a relative one, like titopoquito suggests.

You may also want to post the output of "ls -l my.txt". The file should be in your home directory.
 
Old 12-11-2006, 01:43 PM   #5
bio_informatics
LQ Newbie
 
Registered: May 2006
Posts: 5

Original Poster
Rep: Reputation: 0
realy thanks,

the problem is solved, when i wrote the absolute path in my script it's worked now.

thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 03:14 AM
Problem with crontab PierrePau Linux - Software 3 06-28-2004 03:34 PM
making an entry in crontab through code (perl) akaash Programming 2 05-17-2004 04:36 AM
problem with crontab juanb Linux - Newbie 2 12-16-2003 05:54 AM
crontab problem TomTheNewbie Slackware 1 07-09-2003 08:12 AM


All times are GMT -5. The time now is 06:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration