0

I am trying to pass a file into a program for data processing with bash and I am wondering if I have the correct syntax

/home/mumps/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt | /home/mumps/Medline2012/getDocs.mps > /home/mumps/CS3150/Scripts/HW1/textfiles/Titles.txt

The text files I am sending in are all valid and correctly formatted, but am just getting back a file error from the getDocs.mps (I should note that getDocs does work properly because it was something that my teacher passed out along with the debian vdi and other people aren't having a issue with it.)

getDocs does however call a text file that is located in Medline2012 as well which is where the error is coming from I believe.

1
  • wonder u should do this -- pass as parameter value the i/p and o/p for example in the move command - mv <source-file> <dest-file>... Commented Feb 26, 2013 at 3:09

5 Answers 5

3

Or just use bash redirection throughout without cat.

/home/mumps/Medline2012/getDocs.mps < /home/mumps/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt > /home/mumps/CS3150/Scripts/HW1/textfiles/Titles.txt
Sign up to request clarification or add additional context in comments.

Comments

3
/home/mumps/Medline2012/getDocs.mps < /home/mumps/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt > /home/mumps/CS3150/Scripts/HW1/textfiles/Titles.txt

or

~/Medline2012/getDocs.mps < ~/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt > ~/CS3150/Scripts/HW1/textfiles/Titles.txt

or even

< ~/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt ~/Medline2012/getDocs.mps > ~/CS3150/Scripts/HW1/textfiles/Titles.txt

Comments

2

You either need to cat your .txt file, to pass the contents of it to the script via the pipe,

cat /home/mumps/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt | /home/mumps/Medline2012/getDocs.mps > output

or, depending on what's in the script, it might need to go as a command line parameter, i.e.

 /home/mumps/Medline2012/getDocs.mps /home/mumps/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt > output

3 Comments

didn't realize I needed to cat it before I sent it to the program, Thanks. I will try this when I get home.
Well, cat actually prints the contents of the file, | redirects the stdout of the cat process to the stdin of your script, > redirects the output of the script to the target file. As others suggested, you can also use bash redirection, so < between txt file and the script.
I think I will try the redirection first when I get home because from what I remember about the getDocs.mps it reads the file in though a for loop. and it is getting stuck at an if statement that says if osu.medline exists then do the loop (which it does, but drops to the else statement saying file error)
1

You are trying to execute your data file and feed the results to your script.

try

cat /home/mumps/CS3150/Script/HW1/textfiles/CardioAndPulmonary.txt | /home/mumps/Medline2012/getDocs.mps > /home/mumps/CS3150/Scripts/HW1/textfiles/Titles.txt

Comments

1

If you are still having trouble do a cd to the Medline2012 before you execute getDocs.mps. The reason is because when you access the getDoc.mps it calls to open the osu.medline database. This will cause a "file error" because the call in getDoc.mps does not include the path to osu.medline.

EDIT: A lot of people are telling you that you need to "cat" which is wrong. getDoc.mps has its own printing. If it didn't it wouldn't be printing "file error" for you. I also saw that you said that it is breaking after the loop. Did you test to make sure it isn't at the opening of the file. You can check by adding and indicating word in between the quotes in the first printing of "file error". You could change it to something like "file error 1." I realize you probably know that I just like to be thorough.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.