Abs
Abs

Reputation: 57966

Problem Making C++ script

I am not sure if I can post this sort of question (apologies in advance) but I am trying to build something from this blog post.

# mkdir wkthumb
# cat > wkthumb.cpp

# qmake -project
# qmake && make
# ./wkthumb

I have no experience with this, but I download all the files needed in the directory wkthumb using git. I have gone inside this directory and tried to execute cat > wkthumb.cpp - this just hangs for me. In addition, I thought cat was supposed to be used like this: cat file1.txt file2.txt > file3.txt? The above is blank with the first arguments?

I am using Fedora Core 10.

Upvotes: 0

Views: 110

Answers (4)

Michaelkay
Michaelkay

Reputation: 258

When this appears in a script it takes input from stdin (the keyboard). I'm guessing, but I think you are supposed to type (or paste) the C++ program listed below the script.

Upvotes: 0

Andy White
Andy White

Reputation: 88475

If you run cat without file argument(s), it reads input from stdin. If you run it like he's doing, it will basically read whatever you type, and pipe it into the file, until you hit CRTL-D (EOF).

Upvotes: 0

pm100
pm100

Reputation: 50210

cat with no input is expecting to read from the console. THis is why it appears to be hanging

put

 cat > wkthumb.cpp <<"END"
 ..
 c++ code from blog
 ...
 END

Upvotes: 0

Greg Hewgill
Greg Hewgill

Reputation: 994599

The command

cat > wkthumb.cpp

reads from stdin and writes to the file wkthumb.cpp. When you run that it's not hanging, but rather it's waiting for you to type some source code. Copy and paste the source code in that blog post, followed by CtrlD Enter to create the wkthumb.cpp file.

Or, if you've already downloaded wkthumb.cpp through some other method, simply skip the above step.

Upvotes: 2

Related Questions