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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-23-2012, 05:17 PM
|
#1
|
|
LQ Newbie
Registered: Feb 2007
Posts: 4
Rep:
|
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?
Last edited by itsnew2me; 11-23-2012 at 05:19 PM.
|
|
|
|
11-23-2012, 05:22 PM
|
#2
|
|
LQ Newbie
Registered: Oct 2012
Posts: 24
Rep: 
|
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
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?
|
|
|
|
|
11-23-2012, 05:24 PM
|
#3
|
|
Senior Member
Registered: May 2005
Location: boston, usa
Distribution: fc-12/ fc-11-live-usb/ aix
Posts: 2,672
|
did you edit the script in windows.
ms new-lines are different from *-nix new-lines.
|
|
|
2 members found this post helpful.
|
11-23-2012, 07:49 PM
|
#4
|
|
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,617
|
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
|
|
|
|
11-24-2012, 07:57 AM
|
#5
|
|
LQ Newbie
Registered: Feb 2007
Posts: 4
Original Poster
Rep:
|
That solved it!
It was indeed the problem with Windows line endings instead of Linux.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:30 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|