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 11-23-2012, 05:17 PM   #1
itsnew2me
LQ Newbie
 
Registered: Feb 2007
Posts: 4

Rep: Reputation: 0
bash script - don't understand error


I wrote my first shell script to copy files for backup:

#!/bin/bash
cp /media/A2AC7FD5AC7FA289/zip/Rohan.ts /media/KINGSTON/Store
cp /media/KINGSTON/Store/roback.tc /media/A2AC7FD5AC7FA289/zip

The commands work when typed individually at a terminal, but when I run the script, I get an error about 'invalid argument', because it seems that \r has been appended to the original line. See attached screenshot.

What am I missing?
Attached Images
File Type: png Screenshot from 2012-11-23 17:55:25.png (29.0 KB, 19 views)

Last edited by itsnew2me; 11-23-2012 at 05:19 PM.
 
Old 11-23-2012, 05:22 PM   #2
mohitnarula
LQ Newbie
 
Registered: Oct 2012
Posts: 24

Rep: Reputation: Disabled
Wrong Slash probably?

I just had a quick look and the first thing I noticed is you got a forward slash instead of a Backward slash, try changing that and see if it works.

Mohit

Quote:
Originally Posted by itsnew2me View Post
I wrote my first shell script to copy files for backup:

#!/bin/bash
cp /media/A2AC7FD5AC7FA289/zip/Rohan.ts /media/KINGSTON/Store
cp /media/KINGSTON/Store/roback.tc /media/A2AC7FD5AC7FA289/zip

The commands work when typed individually at a terminal, but when I run the script, I get an error about 'invalid argument', because it seems that \r has been appended to the original line. See attached screenshot.

What am I missing?
 
Old 11-23-2012, 05:24 PM   #3
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-19-live-usb/ aix
Posts: 3,840

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
did you edit the script in windows.
ms new-lines are different from *-nix new-lines.
 
2 members found this post helpful.
Old 11-23-2012, 07:49 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 285Reputation: 285Reputation: 285
Code:
cp /media/A2AC7FD5AC7FA289/zip/Rohan.ts /media/KINGSTON/Store
In screenshot, it's mentioned $'/media/KINGSTON/Store'. Did you check that dir. /media/KINGSTON/Store exists or not? If it's existing then simply use it's full path in script, not with a $:
Code:
cp /media/A2AC7FD5AC7FA289/zip/Rohan.ts /media/KINGSTON/Store
cp /media/KINGSTON/Store/roback.tc /media/A2AC7FD5AC7FA289/zip
 
Old 11-24-2012, 07:57 AM   #5
itsnew2me
LQ Newbie
 
Registered: Feb 2007
Posts: 4

Original Poster
Rep: Reputation: 0
That solved it!

It was indeed the problem with Windows line endings instead of Linux.
 
  


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
i have tried to view this error message don;t seem 2 understand shygvy Programming 1 05-14-2012 11:44 AM
[SOLVED] Don't Understand Duplicate File Descriptors in Bash dcparris Linux - Server 3 12-28-2011 11:27 PM
[SOLVED] I don't understand this error message... ScottSmith Programming 3 11-16-2009 10:57 AM
Don't understand dependency error johngcarlsson Linux - Newbie 2 05-29-2008 06:49 PM
I don't understand this error FowlProgrammer Linux - Newbie 4 02-18-2007 07:42 AM


All times are GMT -5. The time now is 01:33 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration