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.
Hi!
I want to write a simple script under UNIX\Linux OS, that finds your login in /etc/passwd
and prints your login and the following 3 logins to a HTML file (named logins.html) to a table.
I Know, that its easy, but I have some problems, and I can't find the error...
If anyone can help me...
Many many many thanks in advance!
hi there,
your script need some work. i will give you part of the info. afterwards you can build the script by yourself.
with grep you can reach the following...
Code:
grep -A 3 `whoami` /etc/passwd
with this you get your info, plus the next 3. you need to "clean it" before inserting in a html code.
regards,
slackie1000
Thank you for the info. This part is now working... But I want to put this information on a table. Th 1st column with the logins, teh 2nd column with the userIDs associated with the
logins in 1st column and the 3rd column with the home directories for the
logins in 1st column.
I would be gratefull if you could help me one more time. I´ll pay you a beer in Portugal or in Germany. Many thanks, Symbalino.
Many thank for the help, now the program is working very well!!!
But, the last thing that I need is, for example, if there is a parameter on the command line, I need that the script will print the datas for the login specified in that parameter.
Example for running the script:
1.) ./myscript -> prints the datas for your login and the following 3 logins in
/etc/passwd
2.) ./myscript xlogin25 -> the same for xlogin25
And this, really I dont Know how to do!!!
And I promess that this is My last post abou this script
#! /bin/bash
myself=$1
if [[ ! "$myself" ]]
then
myself=$( whoami )
fi
first=... [that ugly stuff]
Now, does this also earn me a beer?
oh. which ugly stuff you mean?
symbalino, how can you get such task if don't know some script language. we are talking here about basics. 10 s in google and you will find your answer. i gave you 90% of the information. if you want to refer the first command line parameter in your code use "$1". if you want the next three entries, you "-A 3" with grep. can you put the pieces together now?
regards,
slackie1000
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.