Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Hey guys,
I really hope I'm in the right place.
We're using a Linux server for mail distribution at my workplace and need a script to employ via SSH if possible to do the following:
List all users with mail above 25MB
Filter specific usernames of our choosing
Print this list (not necessary)
We SSH via Windows machines.
You don't 'script' in SSH..that's a method of connecting over a network, either for terminal or data transfer. And yes, it's very possible to easily write a bash shell script on the Linux system, to do what you're after, and RUN that script after connecting via SSH.
However, please read the "Question Guidelines" link in my posting signature. We will be glad to HELP you with a script, but we WILL NOT write a script for you. You will have to post what efforts you've made of your own, and tell us where you're stuck, as well as explain more about what you expect the script to do. For example:
You don't tell us what mail system you're using, so we don't know where to tell you to look.
You don't say how you are going to choose what user name to look for
If it's not necessary, why include it? If you DO want to print it, you will obviously need to tell us how the printer is connected
You don't 'script' in SSH..that's a method of connecting over a network, either for terminal or data transfer. And yes, it's very possible to easily write a bash shell script on the Linux system, to do what you're after, and RUN that script after connecting via SSH.
However, please read the "Question Guidelines" link in my posting signature. We will be glad to HELP you with a script, but we WILL NOT write a script for you. You will have to post what efforts you've made of your own, and tell us where you're stuck, as well as explain more about what you expect the script to do. For example:
You don't tell us what mail system you're using, so we don't know where to tell you to look.
You don't say how you are going to choose what user name to look for
If it's not necessary, why include it? If you DO want to print it, you will obviously need to tell us how the printer is connected
You don't tell us how you're doing this now
Thank you for your reply.
I did not ask to know how to "script in ssh" (haha), I said I would like to write a script to employ via ssh.
I'm not sure which mail system is being used - I've been kind of dropped into the middle of a mess.
As for how I'm going to "choose what username to look for" I'm not sure what you mean. I just need to list all users (directories) that are over 25MB.
And the printing is not necessary, but it would be nice. It's more of an idea than a necessity.
I can see by your response that you are used to people coming here and demanding answers with little thought or explanation, but I wish you would've read my post more carefully. I am also sorry that I left some things out and was a little too brief in my explanation.
Anyways - I'm guessing the grep command would be a good start? I'm pretty inexperienced when it comes to Linux command line.
I'm not sure which mail system is being used - I've been kind of dropped into the middle of a mess.
Well, if that is the case, I would start out by using ssh to log into the machine, and then "manually" find the directories which contain mail for the different users (/home/<user>/mbox perhaps?). Until you have an idea about what to search for (and where), writing a script is futile.
Thank you for your reply.
I did not ask to know how to "script in ssh" (haha), I said I would like to write a script to employ via ssh.
Understand, but did want to clarify this before you went further.
Quote:
I'm not sure which mail system is being used - I've been kind of dropped into the middle of a mess.
Then that needs to be your 'step 1'...figure out what's being used. Different mail systems keep mail in different locations. Until you figure out WHERE, and what those files are named, there's not going to be a way to find out which are the large files.
Quote:
As for how I'm going to "choose what username to look for" I'm not sure what you mean. I just need to list all users (directories) that are over 25MB.
In your first post, you listed at point #2, "Filter specific usernames of our choosing"...what do YOU mean? It certainly implies that you want to (somehow) give this script a user name(s) to filter by. HOW do you plan on doing that? Command-line? Web form? File?
Quote:
And the printing is not necessary, but it would be nice. It's more of an idea than a necessity.
Great, and that's easily done. So as asked, how is the printer connected?
Quote:
I can see by your response that you are used to people coming here and demanding answers with little thought or explanation, but I wish you would've read my post more carefully. I am also sorry that I left some things out and was a little too brief in my explanation.
Thanks, but I read your post carefully....what part of the response indicated that I didn't?? You omitted any details which would help anyone help you..without them, no one, ANYWHERE, is going to be able to give you any advice. I realize you say you've been dropped into the middle of this, but you must have some of the skills and information available, since you were given this job to do.
Your first step needs to be basic research. What version/distro of Linux are you using? What mail system? How do you want this program to work? Very basic things that no one here is going to be able to tell you. After that, how is this task being performed now? Is there any part of that process that you can use?
Quote:
Anyways - I'm guessing the grep command would be a good start? I'm pretty inexperienced when it comes to Linux command line.
Since you've not given us any details, we can't tell you if grep will be used at ALL, much less give you a good start. Grep is a search utility...again, without knowing what to search, and how you're going to pass those search parameters to your program, there's little we can tell you.
Understand, but did want to clarify this before you went further.
Then that needs to be your 'step 1'...figure out what's being used. Different mail systems keep mail in different locations. Until you figure out WHERE, and what those files are named, there's not going to be a way to find out which are the large files.
In your first post, you listed at point #2, "Filter specific usernames of our choosing"...what do YOU mean? It certainly implies that you want to (somehow) give this script a user name(s) to filter by. HOW do you plan on doing that? Command-line? Web form? File?
Great, and that's easily done. So as asked, how is the printer connected?
Thanks, but I read your post carefully....what part of the response indicated that I didn't?? You omitted any details which would help anyone help you..without them, no one, ANYWHERE, is going to be able to give you any advice. I realize you say you've been dropped into the middle of this, but you must have some of the skills and information available, since you were given this job to do.
Your first step needs to be basic research. What version/distro of Linux are you using? What mail system? How do you want this program to work? Very basic things that no one here is going to be able to tell you. After that, how is this task being performed now? Is there any part of that process that you can use?
Since you've not given us any details, we can't tell you if grep will be used at ALL, much less give you a good start. Grep is a search utility...again, without knowing what to search, and how you're going to pass those search parameters to your program, there's little we can tell you.
Thanks again for your reply!
I'll have to do some more investigation I guess! The users are stored as directories in the following way:
/u1/mail/user1
/u1/mail/user2
Etc.
I didn't know the distro/system type would matter that much. Like I said, I'll have to do some investigation. I can't begin to explain the undocumented/unlabeled spaghetti mess of a server room this box is in. I was hoping to be able to do this little bit without getting too dirty.
Thanks again for your reply!
I'll have to do some more investigation I guess! The users are stored as directories in the following way:
/u1/mail/user1
/u1/mail/user2
Etc.
That's a start, but you also need to know WHAT is stored in those directories. Could be a database file, which may be very static in size...could also be maildir files, which increase/decrease with every mail received/deleted.
Quote:
I didn't know the distro/system type would matter that much. Like I said, I'll have to do some investigation. I can't begin to explain the undocumented/unlabeled spaghetti mess of a server room this box is in. I was hoping to be able to do this little bit without getting too dirty.
If you don't know anything about Linux, scripting, etc., this isn't a 'little bit'. The version/distro matters, because the versions of tools you may have on an old server give different output than on a new one.
Again, details matter. Since you don't know anything about Linux (assuming, based on your posts), who put that server in, and can you ask them?
That's a start, but you also need to know WHAT is stored in those directories. Could be a database file, which may be very static in size...could also be maildir files, which increase/decrease with every mail received/deleted.
If you don't know anything about Linux, scripting, etc., this isn't a 'little bit'. The version/distro matters, because the versions of tools you may have on an old server give different output than on a new one.
Again, details matter. Since you don't know anything about Linux (assuming, based on your posts), who put that server in, and can you ask them?
No. No. I have figured out my answer, and it was much simpler than you (seemingly love to) make it out to be.
I took this position over from a guy who seems to be much like you. His pretentious/know it all stick in the mud (and rear) attitude got him far. And alienated those who would've loved to learn from him.
No. No. I have figured out my answer, and it was much simpler than you (seemingly love to) make it out to be.
I took this position over from a guy who seems to be much like you. His pretentious/know it all stick in the mud (and rear) attitude got him far. And alienated those who would've loved to learn from him. Thank you for your time. And condescension.
Glad you figured it out, but not exactly sure what your problem is.
I didn't insult you, and was not condescending. I asked you questions, and gave you avenues to research, since you (and basing this on what YOU posted), didn't know how to do any of this, and were 'dropped in the middle', according to you. I tried to help you, and got this answer and attitude in response. Good luck getting help from anyone, anywhere, with this kind of response.
I took this position over from a guy who seems to be much like you. His pretentious/know it all stick in the mud (and rear) attitude got him far. And alienated those who would've loved to learn from him.
Thank you for your time. And condescension.
HAHAHA!
This is awesome. Here comes a dude (clanderson), looking for help, which he also gets, FOR FREE.
Everybody in this thread has been polite. But when the OP (clanderson) somehow figures out how to solve his own problem, he turns into an ******* and starts bashing the people who have BEEN TRYING TO HELP. Err... ok!?!
I don't know man, but judging by your (bad) behaviour and (lack of good) manners, that alienation you feel might just be warranted.
Good luck in the future (you're gonna need it!),
HMW
PS. Well, one good thing - apart from TB0ne's very much valid posts - to come out of this thread is that I now know how to use the "ignore" function at LQ. DS.
Last edited by HMW; 09-22-2015 at 08:10 AM.
Reason: Added PS
I was hoping to be able to do this little bit without getting too dirty.
Grow a pair. Dig in.
Maybe when you do you'll lose the attitude and learn something in the process.
LQ is not a cafeteria-style Linux HelpDesk. You don't get to say I want this not that when some one takes their valuable time to reply.
I bet we put more into solving your issue than you did.
We are experienced volunteers with collectively hundreds (or thousands?) of years of experience, and you're asking us for help.
Tossing out "much like you" and "pretentious" and "condescension" is no way to ask for help.
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602
Rep:
clanderson,
Welcome to LQ. Glad you were able to solve your own problem. It would be helpful to the rest of the community of you'd be willing to post your solution, in the event other members have a similar need. Additionally, please be aware that being friendly and respectful to your fellow LQ members is integral to how the site operates. If you have any questions, let us know. http://www.linuxquestions.org/questi...#faq_welcomelq may be of additional help.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.