BestTechie Forums: Problem using files as input for C programs using shell - BestTechie Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem using files as input for C programs using shell


#1 User is offline   Faceless 

  • Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 08-February 12

Posted 08 February 2012 - 09:36 PM

Hi everyone,

I'm fairly new to UNIX and I'm having some problems with my programs. I wrote a program in C that would take input from a file and strip it of its comments. Now when I try to run the command:

q1 < testFiles

in my terminal, it says "q1: command not found". q1 is the name of my program I wrote in C, I believe this is called input redirection. I've been searching google and trying to make sense of this for the past hour but to no avail. My professor says he uses the Bourne shell but that was of no help to me. It works on the computers we have at university, just not on my home linux computer. I'm running XFCE just like my school does as well, this is really starting to annoy me.

If anyone has any insight on this it would be greatly appreciated as I have been going absolutely nowhere on this so far.

Thanks!

#2 User is offline   baker7 

  • USCG: Semper Paratus: "Always Ready"
  • Group: Contributor
  • Posts: 796
  • Joined: 16-August 05
  • Location:Barre, Vermont USA
  • Operating System:Windows 7 Pro, Windows 2000 Pro, Windows MCE/XP Pro, Windows XP Home, Windows 2003 Server SBS, Debian Linux, RedHat Linux, ELive Linux

Posted 16 January 2013 - 01:04 PM

View PostFaceless, on 08 February 2012 - 09:36 PM, said:

Hi everyone,

I'm fairly new to UNIX and I'm having some problems with my programs. I wrote a program in C that would take input from a file and strip it of its comments. Now when I try to run the command:

q1 < testFiles

in my terminal, it says "q1: command not found". q1 is the name of my program I wrote in C, I believe this is called input redirection. I've been searching google and trying to make sense of this for the past hour but to no avail. My professor says he uses the Bourne shell but that was of no help to me. It works on the computers we have at university, just not on my home linux computer. I'm running XFCE just like my school does as well, this is really starting to annoy me.

If anyone has any insight on this it would be greatly appreciated as I have been going absolutely nowhere on this so far.

Thanks!


Good Afternoon :)

Try this: you may have to chage the mode (chmod u+x g1) because if this file is executable file, it will not run without being Executable. Second, when I have to run an executable, I have to use a ./programname to get it to run. so you should try to do

./q1 <testFiles .


and see what happpens

Let me know if this works for you ;)

Brian

This post has been edited by baker7: 16 January 2013 - 01:07 PM


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users