LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-21-2015, 08:37 AM   #1
clanderson
LQ Newbie
 
Registered: Sep 2015
Posts: 4

Rep: Reputation: Disabled
SSH Script to list and filter specific users


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:
  1. List all users with mail above 25MB
  2. Filter specific usernames of our choosing
  3. Print this list (not necessary)

We SSH via Windows machines.
 
Old 09-21-2015, 08:44 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,646

Rep: Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969
Quote:
Originally Posted by clanderson View Post
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:
  1. List all users with mail above 25MB
  2. Filter specific usernames of our choosing
  3. 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:
  1. You don't tell us what mail system you're using, so we don't know where to tell you to look.
  2. You don't say how you are going to choose what user name to look for
  3. 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
  4. You don't tell us how you're doing this now
 
Old 09-21-2015, 09:15 AM   #3
clanderson
LQ Newbie
 
Registered: Sep 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
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:
  1. You don't tell us what mail system you're using, so we don't know where to tell you to look.
  2. You don't say how you are going to choose what user name to look for
  3. 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
  4. 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.
 
Old 09-21-2015, 09:40 AM   #4
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by clanderson View Post
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.

Best regards,
HMW
 
Old 09-21-2015, 09:59 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,646

Rep: Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969
Quote:
Originally Posted by clanderson View Post
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.
 
1 members found this post helpful.
Old 09-21-2015, 11:24 AM   #6
clanderson
LQ Newbie
 
Registered: Sep 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
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.
 
Old 09-21-2015, 12:34 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,646

Rep: Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969
Quote:
Originally Posted by clanderson View Post
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?
 
Old 09-21-2015, 12:45 PM   #8
clanderson
LQ Newbie
 
Registered: Sep 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
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.

Thank you for your time. And condescension.
 
Old 09-22-2015, 07:29 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,646

Rep: Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969Reputation: 7969
Quote:
Originally Posted by clanderson View Post
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.
 
2 members found this post helpful.
Old 09-22-2015, 08:03 AM   #10
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by clanderson View Post
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
 
1 members found this post helpful.
Old 09-22-2015, 11:43 AM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by clanderson View Post
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.
 
2 members found this post helpful.
Old 09-22-2015, 02:01 PM   #12
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
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.

--jeremy
 
1 members found this post helpful.
  


Reply



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
Chroot specific users to ssh linom Linux - Security 1 08-20-2015 10:07 AM
ssh works for all users except specific user (connection reset by peer) fcbman Linux - General 11 08-28-2014 08:35 AM
how to restrict SSH - WinSCP access for Users only to a specific directory??? cyberdome Linux - Security 1 08-21-2014 12:24 AM
Dansguardian - Won't filter new addresses added to filter list TechnoBod Linux - Software 1 01-08-2008 01:40 AM
Shell Script - filter list eluzi Linux - Software 3 03-17-2006 06:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:58 PM.

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
Open Source Consulting | Domain Registration