Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
That gets just a little bit tricky; i.e., what do you mean by "a line of text?" (and, no, I'm not being a smartypants, it matters). In Linux (and all Unix-like systems) a line of text is terminated by a line feed (and there's no carriage return). Windows, on the other, uses a carriage return and line feed pair to terminate lines (and you'll need to deal with that carriage return character). You may also have fixed-length records (where a "line" is exactly, for example, 128 bytes and there is no line termination character). Then, do you mean you want to read a line from a file, stop reading and do something or just read and display without stopping?
At its simplest, here is a sample that requires the file name to be in the source code (not a good way to do things, but it's easy for now). All this program does is open the file, read it and write the output on the standard output (that'll be your terminal window):
Code:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int c;
FILE *infile;
if ((infile = fopen ("your_text_file_name", "r")) == (FILE *) NULL) {
(void) fprintf (stderr, "Can't open your_text_file_name\n");
exit (EXIT_FAILURE);
}
while ((c = getc (infile)) != EOF)
(void) putchar (c);
(void) fclose (infile);
exit (EXIT_SUCCESS);
}
If you save this program as, say, prog01.c, use a text editor and change all the your_text_file_name to your actual text file name and you would then enter
Code:
make prog01
and
prog01 (to execute it)
As you can imaging, this ain't the best way to do this.
Here's a better way: this is a sample program that accepts two arguments, an input file name and an output file name and it copies from the input file to the output file:
You could save this one as prog02.c, enter make prog02 and then execute it.
The first sample read from a file and displays what it read on your terminal screen; the second one is essentially a really simple version of the cp utility.
So, how do you handle winders files (that pesky carriage return character)? Well, in the while loop you can simply
Code:
while ((c = getc (infile)) != EOF) {
if (c == '\r')
continue;
(void) putc (c, outfile);
}
The braces ({}) are important! What this says is, if you see a carriage return, just go get the next character; i.e., don't "putc" that charcter on the output.
How about stopping at the end of a line? This is quick and dirty (which means you really don't want to do it too often)
What that says is, if you see a carriage return ignore it, put the character you just read on the output, if that character is a line feed, put "Hit enter:" on the output and sit there and wait until the user hits the enter key.
Now, you really need to find yourself an introduction to C programming book (I recommend Steven Kochan's Programming in C, 3rd Edition (see http://www.kochan-wood.com); it's well written, covers all the basics (and a little more). Excellent book.
I think what he means is how to access raw coding in a text editor. I searched and downloaded and did all else, yet I have still to see a coherent write-up on how to start simple coding in C or whatever. I know about Emacs and vi/m, but how do you do it?
You may type up a program and then how do you get it to compile in say C? Then how do you run it? How do you attach a desk top icon to it for instant use?
It's all very well to say that Linuxers are more knowledgeable than Windozers, but this simple stuff makes it unnecessarily difficult for newbies.
Yes, that reminds me of the Lattice C compiling environment I had in the 1980's on my Amiga A500. Editor, debugger the works, all in one. Just couldn't get it to compile since I had no proper support to solve problems. TCP/IP was a garage project then. Spent about US$10 grand and got nowhere. The US$1.00 then was ZAR0.95.
However the heady wine of freedom is highly intoxicating.
Anisha, Yes on both counts as in your links. After my last post I tried several other things yet could not get it to work. However; your hints will definitely be followed up.
Anisha, that's where the frustration started. I installed the Evermore Integrated Office suite and created a link like that. But! but, but I got two other files; a tmp and another one with it on the desktop. That is in the Desktop Folders view. Fedora 11 was uninstalled in the meanwhile. Re-installed EIO and added an icon through right click on the kick off menu. Works.
Then did tar firefox.gz and it's all there, but no icon, even an "icon" file in CLI, nil else. Then tried to get one for Firefox through another method, but just got a hollow gear for an Icon and it did not open the app. Had to go Find Files as a quicker method than console. Click on the firefox-bin file to open it. Neither kick off or classic start menu has Firefox as an icon.
Just tried to get into the Firefox directory to make sure that I actually did do 'make install', but now it says there is no such file or folder.
Maybe download Fedora 12 to see of there are any changes in that installation package.
Then did tar firefox.gz and it's all there, but no icon, even an "icon" file in CLI, nil else. Then tried to get one for Firefox through another method, but just got a hollow gear for an Icon and it did not open the app. Had to go Find Files as a quicker method than console. Click on the firefox-bin file to open it. Neither kick off or classic start menu has Firefox as an icon.
I couldn't understand this!
Kindly elaborate!
Is Firefox already installed and running and u want to create a shortcut for it ?
Firefox is installed but not running like in the Windows Start Menu. I'll put my money on it that I did not do the "make install" command after "make". It may be that this is the reason why the Firefox installation is not quite complete.
Yes, I do want a desktop icon. Actually, my Windows computer has ten toolbars with some 100 shortcuts. I do PC management and business directly from the Desktop. Haven't yet seen this facility on Fedora, but between the task tray and selected DT icons I can get by on Fedora. Then again, Linux does not need all that management, while the System Settings are more than enough to do excellent management. Here I need only Dolfin, Evermore Office, Firefox, Thunderbird and some small open source utitlities ("inside" Fedora) to do all I want. This is no Windows mentality. Linux will not compete if it cannot match or better Windows.
Computers aren't gods, they're tools - very quick idiots. Alas, one cannot throw this tool away if it does not work, things have become too fast already.
I'm new to this, so there would've been confusion in trying to get working habits embedded. I'm still writing down everything I do since it does happen that the thing crashes and you have to do it all over again. Trade-off between speed and learning.
Yes, Fedora 3 had FF as part of it. FC 11 not so. Did "locate firefox" weeks ago and got no result. Before that I downloaded Firefox and the Bird and saved the files. They were installed and I had icons on the desktop. Used the saved files with this install to save downloads and to learn untarring.
Did what you asked with "firefox" and got "command not found" on both counts.
Then did "locate firefox" and got reams of stuff - all bits and pieces needed to make firefox work. There are two main directories shown:-
Then did cd /home/cardi
did "ls"
and got several directories and files yet no .mozilla there.
Then did cd /home/cardi/usr
did "ls"
and got Firefox Thunderbird.
I made these in an effort to get some organisation going. I untarred both apps in these. Hence the second /firefox.
Now when I do cd Firefox it gives me "No such file or directory".
It seems Linux is given to working very directory specific. I also tried yum remove firefox without any real conviction of getting results. Sure enough, there was an error about some name resolution not successful.
I think I will simply strip and start over.
One question please. In Konsole, how do I delete a File or Directory?
Open Konsole. Copy paste the EXACT following line on your shell prompt!
Code:
tar -xf firefox-3.5.7.tar.bz2
The above code shall untar the compressed firefox tar ball in your home folder and store it automatically in a folder named firefox
Copy paste the EXACT following lines one by one on your shell prompt!
Code:
su
ln -s /home/cardi/firefox/firefox /usr/bin/
Now type firefox on the terminal and tell the results
___Explanation of the above code___
Whenever you try to execute a file from the shell prompt, the shell tries to find the command in some special directories owned by the root.
The /usr/bin is one of those special directories!
Now to be able to run firefox from anywhere, you have to create a softlink in /usr/bin/ directory with respect to the executable to want to run from anywhere!
su
This asks u for the root password
ln -s /home/cardi/firefox/firefox /usr/bin/
And this creates a softlink in /usr/bin/ directory with respect to the executable file namely "firefox" stored in your home in the folder named firefox
Thanks Anisha, this really helps me very much. Do please give me some time to get to all this as I'm a bit pushed to earn a crust.
Yes, I did use the correct commands literally copied from some site. Did do my homework. Firefox actually works when I use KFind (the Find files and folders app I mentioned earlier as a speedy access method) on the GUI. It is the file /home/cardi/usr/Firefox/firefox/firefox-bin. But, I'm a sucker for running a slick box. Funny how old lessons stick. Our tutor warned against using a computer as a calculator.
I'd just like to see if I can create a link on the desktop from that icon in that dialog. Will let you know.
Despair I won't. Still a bit of a drag, yet it's amazing how the pathways are trampled open again.
Thanks, more than anything else, you save me huge amounts of time. This is very valuable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.