ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I want to be able to display the content of text file on website. For example, to see the output of the command "cat /somedir/somefile" on the webpage.
If all you want to do is read a file and display it, the readfile function is better, since the server doesn't have to start a shell on every page hit.
as far as i know the backticks operator works without invoking a shell but of course the readfile function could be used as well.
exec, passthru and backticks are functions to invoke/execute other scripts and programs so one has to be careful with dynamically posted commands here.
gives me the text file unformatted, sort of cannot detect end of line, and exec ("/bin/cat myfile.txt", &$output); gives me an array. I am sure i am close to solution here, will try to manipulate the output, or printout the array and see how its going...
Guys could you please help me with this one, it must be something very simple but i am failing to fix to: Whatever i tried from the above mentioned solutions i am getting this output:
The "problem" here (not a real problem, just straightforwardness) is that in bash CRLF translates to a new line on your screen, while in HTML you need a <br> tag to accomplish the same.
The backtick or read method work as well, you only must put some effort in translating CRLF (or just CR in the Linux world, or was it LF?) into <br>. It is the old tradeoff between quick coding and efficient code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.