Sponsored Content
Top Forums Shell Programming and Scripting Having trouble writing a basic shell program Post 302098094 by SeanWuzHere on Thursday 30th of November 2006 12:41:05 PM
Old 11-30-2006
Quote:
Originally Posted by Perderabo
This might get you started....
Code:
$ cat bashfiles
#! /usr/local/bin/bash

for arg ; do
        case $arg in
        *.tar)
                echo $arg is a tar file
                ;;
        *.Z)
                echo $arg is a compressed file
                ;;
        *.gz)
                echo $arg is a gzipped file
                ;;
        *)
                echo $arg is an unsupported file type
                ;;
        esac
done
exit 0
$ ./bashfiles a b c d e f g h i j k  a.tar b.gz c.Z
a is an unsupported file type
b is an unsupported file type
c is an unsupported file type
d is an unsupported file type
e is an unsupported file type
f is an unsupported file type
g is an unsupported file type
h is an unsupported file type
i is an unsupported file type
j is an unsupported file type
k is an unsupported file type
a.tar is a tar file
b.gz is a gzipped file
c.Z is a compressed file
$


Thanks man! That is awesome! Thank you so much. Smilie
 

9 More Discussions You Might Find Interesting

1. Programming

Basic questions on writing a Unix Service (newbie help!)

Hi there. I've got 12 years experience writing C++ on Windows, and 3 years C# on Windows. Now my boss wants me to write a C++ app to run on Unix as a multithreaded 'service' (i.e. a program that runs with no user intervention). Some quick questions for The Experts: * Whats the best C++... (3 Replies)
Discussion started by: Rutland Gizz
3 Replies

2. Programming

Basic multithreaded program

I'd like to write a program (I'm flexible on language; C/C++ was my original idea but a scripting language would probably be better) that runs hundreds of programs, but only N = 4 (say) at a time. The idea is to keep all the cores on a multicore machine busy. How can I do this? In particular,... (6 Replies)
Discussion started by: CRGreathouse
6 Replies

3. HP-UX

Program monitor on BT-Basic

Hi, The "program monitor" command in BT-Basic prompt you for a user name and a password. How can I grant access only to certain users ? Thank you. (0 Replies)
Discussion started by: fosiceanu
0 Replies

4. Programming

writing a shell program in ubuntu

Hi all, I have an assignment from school to write a shell program in linux. the idea is to exercise fork() and execv() functions.. the shell program is supposed to be the master and every command that the user prints will run in a new process. we also need to try running the command in every... (1 Reply)
Discussion started by: r3vive
1 Replies

5. Homework & Coursework Questions

Need help with Basic Unix Program

I am a newbie to UNIX. I'm learning UNIX on my own, just trying to get the jerk of how things work in UNIX environment. I am familiar with Windows environment. Can anyone pls write simple 'envprint' programs to : 1) List all the environment Information (using the -l or --l options) 2) ... (1 Reply)
Discussion started by: agup17
1 Replies

6. Homework & Coursework Questions

Need help writing a shell script program

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write the a shell script program to remove all space characters stored in the shell variable TEXT.... (7 Replies)
Discussion started by: kofine05
7 Replies

7. Shell Programming and Scripting

Having trouble using expect to launch vpn program

Hello all. I am a linux and linux scripting newbie so please forgive my ignorance. I have been tasked to write what I thought should be a pretty simple script that does the following: 1) Loads our forticlient ssl vpn command line client 2) sends the vpn password to the client Pretty... (2 Replies)
Discussion started by: wblakenc
2 Replies

8. Programming

Trouble compiling program using the readline library.

Hi: in the info page for readline library I read -- Function: void rl_variable_dumper (int readable) Print the readline variable names and their current values to `rl_outstream'. If READABLE is non-zero, the list is formatted in such a way that it can be made part of an... (1 Reply)
Discussion started by: stf92
1 Replies

9. Linux

Trouble setting up basic user authentication on apache2 web server

Hey guys! So I decided to set up some basic user authentication on my apache2 server, and I am running into some problems. I followed the documentation provided by apache on their website, but I cant create the password file for some reason. I did a little trouble shooting myself, and found... (40 Replies)
Discussion started by: LinuxIntern445
40 Replies
ESMTP(1)						      General Commands Manual							  ESMTP(1)

NAME
esmtp - libESMTP to Sendmail compatibility interface SYNOPSIS
esmtp [flags] [address ...] sendmail [flags] [address ...] mailq sendmail -bp newaliases sendmail -bi DESCRIPTION
Esmtp is a send-only sendmail emulator for machines which normally retrieve their mail from a centralized mailhub using programs such as fetchmail. Esmtp does not attempt to provide all the functionality of sendmail: it is intended to be used by mail user agents as mutt. OPTIONS
Most sendmail options are irrelevant to esmtp . Those marked ``ignored'' or ``default'' have no effect on mail transfer. Those marked ``unsupported'' are fatal errors. -Ac (ignored) Use submit.cf even if the operation mode does not indicate an initial mail submission. -Am (ignored) Use sendmail.cf even if the operation mode indicates an initial mail submission. -B type Set the body type to type. Current legal values are 7BIT or 8BITMIME. -ba (unsupported) Go into ARPANET mode. -bd (unsupported) Run as a daemon. -bD (unsupported) Same as -bd except runs in foreground. -bh (unsupported) Print the persistent host status database. -bH (unsupported) Purge expired entries from the persistent host status database. -bi (ignored) Initialize the alias database. -bm (default) Deliver mail in the usual way. -bp Print a listing of the queue(s). -bP (unsupported) Print number of entries in the queue(s); only available with shared memory support. -bs (unsupported) Use the SMTP protocol as described in RFC821 on standard input and output. -bt (unsupported) Run in address test mode. -bv (unsupported) Verify names only - do not try to collect or deliver a message. -C file Use alternate configuration file. -d X (ignored) Set debugging value to X. -F fullname Set the full name of the sender. -f name Sets the name of the ``from'' person (i.e., the envelope sender of the mail). This address may also be used in the From: header if that header is missing during initial submission. The envelope sender address is used as the recipient for delivery status notifi- cations and may also appear in a Return-Path: header. This address is also used to select from different identities in the configuration file. If no envelope sender is specified in the command line then the default identity's address is used. -G (ignored) Relay (gateway) submission of a message. -h N (ignored) Set the hop count to N. -I (ignored) Same as -bi. -i (ignored) Ignore dots alone on lines by themselves in incoming messages. This should be set if you are reading data from a file. -L tag (ignored) Set the identifier used in syslog messages to the supplied tag. -N dsn Set delivery status notification conditions to dsn, which can be `never' for no notifications or a comma separated list of the val- ues `failure' to be notified if delivery failed, `delay' to be notified if delivery is delayed, and `success' to be notified when the message is successfully delivered. -n (default) Don't do aliasing. -O option=value (ignored) Set option option to the specified value. This form uses long names. -o x value (ignored) Set option x to the specified value. This form uses single character names only. -p protocol (ignored) Set the name of the protocol used to receive the message. -q[time] (ignored) Process saved messages in the queue at given intervals. -qp[time] (ignored) Similar to -qtime, except that instead of periodically forking a child to process the queue, forks a single persistent child for each queue that alternates between processing the queue and sleeping. -qf (ignored) Process saved messages in the queue once and do not fork(), but run in the foreground. -qG name (ignored) Process jobs in queue group called name only. -q[!]I substr (ignored) Limit processed jobs to those containing substr as a substring of the queue id or not when ! is specified. -q[!]R substr (ignored) Limit processed jobs to those containing substr as a substring of one of the recipients or not when ! is specified. -q[!]S substr (ignored) Limit processed jobs to those containing substr as a substring of the sender or not when ! is specified. -R return Set the amount of the message to be returned if the message bounces. The return parameter can be `full' to return the entire mes- sage or `hdrs' to return only the headers. In the latter case also local bounces return only the headers. -r name An alternate and obsolete form of the -f flag. -t Read message for recipients. To:, Cc:, and Bcc: lines will be scanned for recipient addresses. The Bcc: line will be deleted before transmission. -V envid Set the original envelope id. -v Go into verbose mode. -X logfile Log all traffic in and out of mailers in the indicated log file. -- Stop processing command flags and use the rest of the arguments as addresses. FILES
~/.esmtprc User configuration file. Only read if no configuration file is specified on the command line. /etc/esmtprc System configuration file. Only read if no configuration file is specified on the command line and there is no user configuration file. SEE ALSO
esmtprc(5), fetchmail(1) AUTHOR
Jose Fonseca ESMTP(1)
All times are GMT -4. The time now is 10:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy