Sponsored Content
Top Forums Shell Programming and Scripting Why do I need this in the script tutorial? Post 302529935 by MaindotC on Saturday 11th of June 2011 12:02:09 PM
Old 06-11-2011
Why do I need this in the script tutorial?

I'm taking a tutorial - intro to Unix Shell Scripting - and the first exercise is a walk-through of writing a script to achieve the following:

"As a network administrator you are collecting configuration information about all FTP servers in the organisation. You need to write a script to collect information about:
- The FTP server that is running.
- The configuration file and its location on the FTP server.
- Permission information of the configuration file.
- Useful content of the configuration file."

I'm sure this is probably a naive script that would make some of you gosu's vomit but just go along with it for now please. SO anyway, it has me enter the following commands to start the script:

Code:
#!/bin/bash
clear
ps ax | grep -v grep | grep ftpd 1> /dev/null || echo "NO FTP service running"
#### end of snippet #####

Now obviously when I finish the script the tutorial prints the desired output. However I don't understand why there are so many greps in this command. For example, I ran the same command on a Ubuntu vm:
Code:
dvorjak@dvorjak:~$ ps ax | grep -v grep | grep ftpd
968 ?         Ss                0:00 /usr/sbin/vsftpd
dvorjak@dvorjak:~$ ps ax | grep -v grep | grep ftpd 1> /dev/null || echo "NO FTP service running"
dvorjak@dvorjak:~$

Why do I need so many greps in that command? Again - I realise this is some tutorial that is presenting this script, not you, but can you guess why they would require this? Just fyi - here's the whole script:
Code:
]#!/bin/bash
clear
ps ax | grep -v grep | grep ftpd 1> /dev/null || echo "NO FTP service running"
CONFIG_FILE=$(ps ax | grep -v grep | grep ftpd | awk '{print $6}')
echo "FTP configuration file on `hostname` is"
basename $CONFIG_FILE
echo "It is located in the directory"
dirname $CONFIG_FILE
echo ________________Detailed information about the file_______________
ls -l $CONFIG_FILE
echo
echo
echo "_______________Non-commented lines in the ${CONFIG_FILE}__________"
cat $CONFIG_FILE | grep -v ^#

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Procmail Tutorial

Hello, Somebody knows a good procmail tutorial in the net? Thanks!:) (1 Reply)
Discussion started by: luiz_fer10
1 Replies

2. UNIX for Dummies Questions & Answers

Unix Tutorial

Any good UNIX tutorials to download? Any good APACHE tutorials? thanks (2 Replies)
Discussion started by: TEKGALAHAD
2 Replies

3. Shell Programming and Scripting

Tk tutorial

Anyone know any good website with a step by step instructions on writing Perl GUI scripts with Tk ??? (3 Replies)
Discussion started by: perleo
3 Replies

4. Post Here to Contact Site Administrators and Moderators

Tutorial forum?

I got this account a while ago and didn't have much time to try it out. After having had some frustration by posting tutorials regarding various Linux activites of mine in my Slashdot journals, it occurred to me that this forum might be better suited. I know I can probably post in the OS specific... (1 Reply)
Discussion started by: deckard
1 Replies

5. IP Networking

RouterSim tutorial.

Hi everyone... Well, this is a kina of help tutorial question. I'm using actually the “RouterSim Network Visualizer” an environment where you can practice and create your own LAN, I will be honest, I'm new to creating and managing networks, but not to new about IP´s. So, the question, anyone... (0 Replies)
Discussion started by: TARFU
0 Replies

6. Shell Programming and Scripting

Shell script tutorial?

Hi All, I have started preparation of Shell script...Can anybody send me the link where I can get a right tutorial or pdf file of shell script... Thanks in Advance (2 Replies)
Discussion started by: kunalpatil09
2 Replies

7. AIX

AIX useful tutorial...

hi guys, I want to learn AIX, I am a beginner for this operating system of IBM. Can anyone give me some useful tutorial for a beginner like me?... Thanks... + GOD bless + ^_^ (1 Reply)
Discussion started by: TechReader
1 Replies

8. Solaris

Need LAMP tutorial!

Hello Everybody, Does anybody know or recommend me a tutorial for LAMP server on Solaris 10 x86? (3 Replies)
Discussion started by: ahmedamer12
3 Replies

9. Web Development

Vue JS 2 Tutorial by The Net Ninja: A Recommended Vue.js Video Tutorial Series

A number of people have asked me how to get started with Vue.js and my reply before today was to Google "Vue.js". That has changed and my recommendation to anyone who wants to learn the fastest growing, easiest to learn and use Vue.js web dev framework is to watch this video tutorial series: ... (0 Replies)
Discussion started by: Neo
0 Replies
uudemon(4)						     Kernel Interfaces Manual							uudemon(4)

NAME
uudemon.admin, uudemon.cleanu, uudemon.hour, uudemon.poll - Administrative shell scripts for polling remote systems, cleaning up spool directories, reporting status to the system administrator, and routine invocations of the uuxqt and uusched daemons SYNOPSIS
These shell scripts reside in the following directory: /usr/lib/uucp DESCRIPTION
All the scripts can be run from the command line or can be run automatically by the cron daemon. To automatically run the scripts, remove the comment character (#) from the beginning of the relevant line in the /var/spool/cron/crontabs/uucp file. This script reports status to the system administrator. It issues the uustat command to find out the status of uucp jobs. It mails the results to the uucp login ID. The script may be modified to send mail to any login ID such as the uucp administrative login ID (uucpa) or root. This script cleans up the /var/spool/uucp and /var/spool/uucppublic directories by running the uucleanup command. The uucleanup com- mand is run with the following parameters: -C7, -D7, X2, -o2, -W1. This script runs the uusched and uuxqt daemons in the background. This script polls the systems listed in the /usr/lib/uucp/Poll file. The uudemon.poll script should be scheduled before the uudemon.hour script. This allows uudemon.poll to create any command files before cron runs the uudemon.hour script. FILES
Contains the uudemon.admin, uudemon.cleanu, uudemon.hour and uudemon.poll files. Contains the uucp file. RELATED INFORMATION
Commands: cron(8), uucleanup(8), uusched(8), uuxqt(1) Files: /usr/lib/uucp delim off uudemon(4)
All times are GMT -4. The time now is 03:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy