[CentOS] [OT] bash here documents
Steve
zephod at cfl.rr.comMon Jun 24 13:58:16 UTC 2013
- Previous message: [CentOS] install java?
- Next message: [CentOS] [OT] bash here documents
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Suppose I have this C++ program:
#include <iostream>
int main (int argc, char** argv)
{
    while (1)
    {
        char cmd[80];
        std::cin.getline(cmd, 80);
        std::cout << "response to " << cmd << std::endl;
    }
}
compiled by: c++ -o junk junk.cpp
and I have this bash script:
#!/bin/bash
./junk <<EOF
blah
bleh
\cC
EOF
echo "Something else"
When I run the script, the program starts and waits for input forever.
I have 2 questions:
1) The "blah" and "bleh" line are not echoed to cout. Why not? Does the here document not send the data to stdin?
2) How do I terminate the program? When run interactively, I use <ctrl>-C. 
Thanks,
Steve
  - Previous message: [CentOS] install java?
- Next message: [CentOS] [OT] bash here documents
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list