Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-04-2010, 01:06 PM   #1
Registered: Sep 2008
Distribution: Fedora 9
Posts: 68

Rep: Reputation: 15
mkdir won't work in a script but works on command line


mkdir -p /cygdrive/c/Blah_Email_Backup/$i
This won't work in a script but it WILL work on the commandline...any suggestions

here is my output when I try the script:

mkdir: cannot create directory `/cygdrive/c/Blah_Email_Backup/\r': No such file or directory
Also, what is the \r at the end of the path in the error??!!
Old 02-04-2010, 01:46 PM   #2
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Show us the code snippet that produces the message?
Old 02-04-2010, 02:25 PM   #3
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Looks like a Windows line end. Was the script created under Windows? The dos2unix command can be used to convert Windows line ends to Linux ones.
Old 02-04-2010, 02:26 PM   #4
Registered: Sep 2008
Location: MN
Distribution: Gentoo, Fedora, Suse, Slackware, Debian, CentOS
Posts: 100
Blog Entries: 1

Rep: Reputation: 20
Most the value of "$i" contains the "CR/LF" line termination from "Windows" (or just the "CR" from Apple) as Linux/UNIX only used the "LF" portion. Easy fix if using BASH is:
mkdir -p /cygdrive/c/Blah_Email_Backup/${i%\\.}


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
Bash script works from command line, fails from cron cmfarley19 Linux - General 4 08-14-2009 12:24 PM
works on command line but not in bash script tara Linux - General 7 02-09-2009 03:57 AM
Perl Script works from command line, but not when evoked by Nagios gfem Linux - General 10 06-05-2008 03:59 PM
Perl shell-out to script dunna work. Works on command line. Why? jlangelier Linux - Software 1 08-28-2004 02:00 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:20 PM.

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