LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-26-2011, 09:29 AM   #1
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Rep: Reputation: 31
Scripting mental block


I'm having a retard moment and I can't figure this out. I have a list of files listed in a error.txt file that I'm trying to copy in a tiny script, but it's doing something and I can't figure out why!

I can echo the file listed:

Code:
[root@testmachine1 rpm_repo]# cat ../error2.txt | awk '{print "echo The filename is "$1}' | bash
The filename is NetworkManager-0.7.0-10.el5_5.2.x86_64.rpm
What doesn't work is when I try and move that file. That file is exactly where the file is showing it, but I keep getting an error saying it ISN'T there.

Code:
[root@testmachine1 rpm_repo]# cat ../error2.txt | awk '{print "ls ../yum/rhel/5/base/"$1}' | bash
: No such file or directoryorkManager-0.7.0-10.el5_5.2.x86_64.rpm
I know it's something simple but I just can't see it. What am I doing wrong? My paths are right, the file is there...my command isn't being interrupted correctly for some reason.
 
Old 07-26-2011, 09:55 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
I suspect a special character in your original file. Notice your output doesn't list the name of the file you expect but rather:

Quote:
No such file or directoryorkManager-0.7.0-10.el5_5.2.x86_64.rpm
Try running a "cat -v" on the original file and see if there is a backspace (^H) or something else showing up in the file.

Also you don't have to cat and pipe to awk - you can run your awk on the file itself:

Code:
awk '{print "echo The filename is "$1}' ../error2.txt | bash
By the way - what are you trying to do piping it to bash? An rpm isn't an executable but rather a package so you'd need to operate on the file using the rpm command.
 
Old 07-26-2011, 10:07 AM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by MensaWater View Post
Try running a "cat -v" on the original file and see if there is a backspace (^H) or something else showing up in the file.
The output looks like there is a carriage return involved.
@OP: Are you trying to edit windows files under linux? If so try running
Code:
sed -i.org 's/\r$//' filename
# or
dos2linux filename
before you execute your script.
 
Old 07-26-2011, 10:13 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
A carriage return would show up a ^M.

Running "file ../errortxt2" might be worthwile to see what kind of file it thinks it is.
 
Old 07-26-2011, 10:43 AM   #5
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Original Poster
Rep: Reputation: 31
That was it!! I knew it was something simple... I'm such a dork!

Also, thanks for the info on awk... I'm a creature of habit and since that's the first way I learned it, I type it out without thinking.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Am I having a PERL mental block??? fusion1275 Programming 12 05-22-2009 02:51 PM
LXer: Has Microsoft gone mental? LXer Syndicated Linux News 11 05-10-2009 10:42 AM
Driving me mental!!!!!! STATIC ROUTES hvc123 Linux - Networking 6 01-15-2009 02:20 PM
Complete Mental Block on MySQL and PHP Pirate96 Programming 5 05-18-2007 01:33 PM
Going mental here!!! n00dles Linux - General 2 10-18-2002 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:07 PM.

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