LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2004, 11:11 AM   #1
bindweb
LQ Newbie
 
Registered: Sep 2004
Posts: 9

Rep: Reputation: 0
Shell scripting error


Hello All,
I have a shell script which uses awstats to generate log files. It has been working fine on red hat linux 7.3, but I recently moved the script to red hat linux 3 Enterprise and its giving error. The problem is in using variables. What happens is that \r is appended to all string variable assignment, which means that a path ends up as /var/www/html/domain1\r\r\r
due to which the folder path becomes invalid.
here is the simple code

#!/bin/sh
save_date=`date +%b%Y`
targetpath=/var/www/html/domain1usage/$save_date
awDomain=domain1
mkdir $targetpath
awPath=/var/www/cgi-bin
perl $awPath/awstats.pl -config=$awDomain -update

what happens is that the targetpath ends up as

/var/www/html/domain1usage/Sep2004\r\r\r

one \r for each time a variable assignment is done.

Please can anyone help me with this, I cannot seem to find any help about it. Thanks a lot in advance.
Imran
 
Old 09-29-2004, 12:17 PM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
try :
Code:
mkdir `echo -e $targetpath | tr -d '\r'`
 
Old 09-30-2004, 06:40 AM   #3
bindweb
LQ Newbie
 
Registered: Sep 2004
Posts: 9

Original Poster
Rep: Reputation: 0
unfortunately it does not work. It creates the same directory as the string name, the string is not resolved to a valid path
 
Old 09-30-2004, 07:30 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you don't use any of those variables more than once in that excerpt, so why not joing them all to a single command?
Code:
mkdir /var/www/html/domain1usage/`date +%b%Y`
no assignments there at all, so presumably no \r's
 
Old 09-30-2004, 10:50 AM   #5
bindweb
LQ Newbie
 
Registered: Sep 2004
Posts: 9

Original Poster
Rep: Reputation: 0
Thank you so very much for your response. Unfortunately I had already tested that, and it does the same appends one \r at the end of it . So I am pretty much clueless as to what do do next.
Imran
 
  


Reply



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
Shell scripting: Print output to logfile, error to logfile & screen stefanlasiewski Programming 18 05-22-2008 12:47 PM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
shell scripting error shouup Programming 8 09-08-2005 12:38 PM
shell scripting carthyc Linux - Newbie 2 07-15-2005 02:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:02 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
Open Source Consulting | Domain Registration