IO Redirect error.

This is a discussion on IO Redirect error. within the Linux Programming forums, part of the Platform Specific Boards category; I created a program to count the number of characters in a file, it compiles fine and is a really ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    19

    IO Redirect error.

    I created a program to count the number of characters in a file, it compiles fine and is a really basic program. When I go to redirect a text file to the program I get an error. chrcnt is the compiled program and words is the text file. I use:

    chrcnt < words

    and I get the error

    chrcnt: program not found

    I am using ubuntu, any ideas as to why its not working?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Try
    ./chrcnt < words
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    19

    Yep

    Quote Originally Posted by Salem View Post
    Try
    ./chrcnt < words
    Yep, that did it. Thank you very much.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    826
    Quote Originally Posted by dtow1 View Post
    why its not working?
    Because by default, current working directory is not one of the directories where executables are searched for.

    Explicitly writing the relative path to the executable (./chrcnt)is just the way you tell the OS to not do any kind of search for it, but just run chrcnt in the current directory. No ambiguity, no search, only results you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DNS Filter ( Redirect)
    By jhsedona in forum C Programming
    Replies: 1
    Last Post: 04-08-2012, 04:20 PM
  2. redirect output
    By Maga in forum C Programming
    Replies: 5
    Last Post: 02-27-2010, 03:58 AM
  3. Redirect stdout using dup
    By spank in forum Linux Programming
    Replies: 13
    Last Post: 04-03-2008, 05:16 PM
  4. Redirect FAQ...
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 05-21-2007, 04:48 PM
  5. DLL Redirect
    By username in forum Windows Programming
    Replies: 5
    Last Post: 05-30-2003, 09:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21