LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2013, 12:10 PM   #1
Prayokshi
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Rep: Reputation: Disabled
./a.out command is not run on fedora 17


I am run the lex and yacc program but it gives the ./a.out error:


[pradnya@pradnya ~]$ su
Password:
[root@pradnya pradnya]# lex forif.l
[root@pradnya pradnya]# yacc -d forif.y
[root@pradnya pradnya]# gcc -c lex.yy.c y.tab.c
[root@pradnya pradnya]# gcc -o in.txt lex.yy.o y.tab.o -ll
[root@pradnya pradnya]# ./a.out
bash: ./a.out: No such file or directory
 
Old 09-25-2013, 12:22 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Code:
# gcc -o in.txt lex.yy.o y.tab.o -ll
That's because you told gcc to name the executable "in.txt". "a.out" is the default, it's only used when you don't explicitly provide an output filename with the "-o" switch, which you did.

http://www.linuxquestions.org/questi...7/#post5028649

Last edited by suicidaleggroll; 09-25-2013 at 12:23 PM.
 
Old 09-25-2013, 12:40 PM   #3
Prayokshi
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks suicidaleggroll
But i dont want output will print on terminal in store in output file and in.txt is the input file which is pass to the lex and yacc program.
 
Old 09-25-2013, 01:15 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
It sounds like you're confusing the compilation and execution stages of your program.

gcc compiles the program, that's all it does. It turns human readable source code into machine readable binary code. It does not take ascii input files, output files, etc. or run the code, all it takes is the source code and turns it into a binary. The "-o" switch in gcc controls what the name of that binary file that it creates will be. In your case, it compiled your code into a binary, and named that binary "in.txt" (an odd name for an executable, but gcc doesn't judge). So your program is now called "in.txt". If you had an "in.txt" file before, it has now been replaced with your new compiled binary.

After your program has been compiled, then you need to run it. This is when you pass any input or output files that your program needs to use during execution. How you pass these files to your program depends entirely on how your program expects to receive input. You might give it the name of the file as a command line argument, or if your program reads from stdin you might cat the file and pipe it to the program, etc.

The process should look something like:
Code:
$ gcc -o thisismybinaryfile lex.yy.o y.tab.o -ll
$ ./thisismybinaryfile in.txt
or
$ cat in.txt | ./thisismybinaryfile
or
$ ./thisismybinaryfile < in.txt
Same goes for the output. You might pass the name of the file to use for output as a command line argument, or the program might dump to stdout and you need to use ">" to redirect that output to a file.

This page has some more information on using lex and yacc:
http://www.cs.bilkent.edu.tr/~guveni...acc/linux.html

Last edited by suicidaleggroll; 09-25-2013 at 01:18 PM.
 
Old 09-25-2013, 03:14 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,817

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
you might want to think of doing a new install
but with a supported version of fedora
fedora 17 is a dead and unsupported version
it went End Of Life ( R.I.P.) back in August of 2013
the current is fedora 19
and fedora 20 should be released in January of 2014
 
Old 09-25-2013, 05:26 PM   #6
Prayokshi
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
thanks suicidaleggroll
but it gives the error

[root@pradnya pradnya]# lex forif.l
[root@pradnya pradnya]# yacc -d forif.y
[root@pradnya pradnya]# cc -c lex.yy.c y.tab.c
[root@pradnya pradnya]# gcc -o thisismybinaryfile lex.yy.o y.tab.o -ll
[root@pradnya pradnya]# ./thisismybinaryfile abc.c
Segmentation fault (core dumped)
[root@pradnya pradnya]# cat abc.c | ./thisismybinaryfile
Segmentation fault (core dumped)
[root@pradnya pradnya]# ./thisismybinaryfile < abc.c
Segmentation fault (core dumped)

Last edited by Prayokshi; 09-25-2013 at 05:30 PM.
 
Old 09-25-2013, 06:06 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
The three commands I provided were just examples of how you could get input data from a file into a program, which one you choose depends ENTIRELY on how your program is written. In fact it's entirely likely that none of them will work, because it depends on how your program expects input.

I can't tell you how to pass information to your program, you're the only one who knows how it works.

The seg fault probably points to a problem with your code. Time to start debugging.

Last edited by suicidaleggroll; 09-25-2013 at 06:10 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run .htm link from command prompt in fedora 10 haribabu1836 Linux - Software 1 06-17-2010 06:08 AM
unable to run su root command in fedora jatin Fedora 4 07-23-2009 06:24 AM
How can Fedora run automatically a Terminal command at the startup? cesar7160 Fedora 4 05-19-2009 12:54 PM
How do I make a command run as root at boot up under Fedora 3? versaulis Linux - Software 5 02-10-2005 07:22 PM
How do I get Fedora to automatically run a command during startup? jlsain Linux - Software 2 03-23-2004 05:03 AM


All times are GMT -5. The time now is 11:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration