Yesu babu Gude
Yesu babu Gude

Reputation: 37

how can I get the SVN head version number in shell and this shell is running continously using the crontab

cat sample.pl

$svn_rev = `svn info -r HEAD | grep Revision: | cut -c11- `;
$rev = `svn info | grep Revision | cut -d' ' -f2` ;
print "SVN Rev of the HEAD:$svn_rev\n";
print "SVN Rev of the Working:$rev\n";

cat sample.sh

perl sample.pl

now running the script like :

./sample

SVN Rev of the HEAD:600
SVN Rev of the Working:590

But whenever running continuously using crontab:

* * * * *  root  /home/sample.sh > /home/sampleout.txt

but here cat sampleout.txt

SVN Rev of the HEAD:
SVN Rev of the Working:590

HEAD revision number shows northing. Please tell me whats the wrong in above and any help would be appreciated.

Upvotes: 1

Views: 561

Answers (2)

Ashwin Bhargava
Ashwin Bhargava

Reputation: 76

The problem is in your cut command. Change the cut -c11- to the cut command you have used in the second line (for $rev)

This should solve your problem!

Upvotes: 1

dethorpe
dethorpe

Reputation: 531

May just be a typo in the post but the script you show is called sample.sh, but in the cron job its sample1.sh, is there maybe a difference between these?

Is the "root" command necassary?, may be best to get it working as your own user first and source your profile in the command to be sure environment is same as when running from command line:

* * * * *  . ~/.profile;/home/sample.sh > /home/sampleout.txt

Upvotes: 0

Related Questions