Sponsored Content
Full Discussion: Shell Scripting n00b
Top Forums Shell Programming and Scripting Shell Scripting n00b Post 302401053 by ASGR on Thursday 4th of March 2010 09:55:21 PM
Old 03-04-2010
No idea. But here's the script for somebody that might me able to help.
(For future reference it's probably better to use the '#' in the toolbar to surrounding your code ;-).
Code:
#!/bin/bash
echo
echo "Your name please."
read STUDENT
echo
echo "Your student ID number please"
read STUDID
echo
echo "Enter submission title please."
read TITLE
echo
echo "Enter submission subtitle please."
read SUBTITLE
echo
echo "Pick course number"
echo
echo "HDWR1000 | PROG1040 | OSYS1000 | SAAD2000"
echo "      DBAS2020 | ICOM1325 | ICOM1200"
read CLASSNUM
echo
echo "Preferred file name?"
read FILENAME
TIM=`date`

	if [ $CLASSNUM=HDWR1000 ]; then
	CLASS=`awk -F":" 'NR==2 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==2 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==2 {print $5}' < dbase.txt`
	elif [ $CLASSNUM=PROG1040 ]; then
	CLASS=`awk -F":" 'NR==3 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==3 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==3 {print $5}' < dbase.txt`
	elif [ $CLASSNUM=OSYS1000 ]; then
	CLASS=`awk -F":" 'NR==5 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==5 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==5 {print $5}' < dbase.txt`
	elif [ $CLASSNUM=SAAD2000 ]; then
	CLASS=`awk -F":" 'NR==4 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==4 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==4 {print $5}' < dbase.txt`
	elif [ $ClassNum=DBAS2020 ]; then
	CLASS=`awk -F":" 'NR==1 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==1 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==1 {print $5}' < dbase.txt`
	elif [ $CLASSNUM=ICOM1325 ]; then
	CLASS=`awk -F":" 'NR==6 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==6 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==6 {print $5}' < dbase.txt`
	elif [ $CLASS=ICOM1200 ]; then
	CLASS=`awk -F":" 'NR==7 {print $1}' < dbase.txt`
		TEACHER=`awk -F":" 'NR==7 {print $2}' < dbase.txt`
		SECTION=`awk -F":" 'NR==7 {print $5}' < dbase.txt`
	else echo "Please restart script."
fi

sed "s/DATETIME/$TIM/" <template.txt >$FILENAME.txt
sed "s/SUBTITLE/$SUBTITLE/" $FILENAME.txt
sed "s/CLASS/$CLASS/" $FILENAME.txt
sed "s/STUDENT/$STUDENT/" $FILENAME.txt
sed "s/STUDID/$STUDID/" $FILENAME.txt
sed "s/TITLE/$TITLE/" $FILENAME.txt
sed "s/SECTION/$SECTION/" $FILENAME.txt  
sed "s/TEACHER/$TEACHER/" $FILENAME.txt


echo
echo "Thank you! Your cover page $FILENAME.txt has been created."
echo

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

OpenBSD N00b: HELP ME!!! AGGGH!!

Note: This is not meant to start a flamewar. I am looking for serious answers to questions regarding OpenBSD. I'm coming to OpenBSD from an eight year background in Linux (specifically various versions of RedHat and now Fedora Core 3). I have some experience with Solaris 8 and HP-UX 11/11i. I... (1 Reply)
Discussion started by: deckard
1 Replies

2. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

3. UNIX for Dummies Questions & Answers

N00b question on CPU % in top

I have a process in my TOP output that is consistantly at 97% usage. I have 16 CPUs on my box. So is the 97% the cumalative usage of all the CPUs or just one? (3 Replies)
Discussion started by: kskywr
3 Replies

4. UNIX for Dummies Questions & Answers

N00b In Need!

Howdy all, just joined the forums after finding them on a good ole' google search. very impressed from what i've seen so far! I'm pretty new to the world of Unix/Linux, have just had a change of job role and been thrown in at the deep end! I'm now working on an Oracle 9i database using HPUX... (1 Reply)
Discussion started by: davesimm
1 Replies

5. Shell Programming and Scripting

scripting n00b question, please help :)

Okay, so I'm a little familiar with C and Linux, but my shell scripting experience is limited to say the least. I know that you begin a shell script with this #!/bin/bash Basically, I've written a C program that's output writes to a shell script. What my problem is, is I would like this shell... (4 Replies)
Discussion started by: beatzz
4 Replies

6. IP Networking

tcp n00b - can't ping router

please help! I have a sun blade with 2 x nics configured, both on different subnets. The eri0 interface (192.168.0.100) is connected to my router (192.168.0.1), but if i try to ping the router, it times out. any suggestions are welcome - i noticed the 2 mac addresses are the same, i've set... (7 Replies)
Discussion started by: badoshi
7 Replies

7. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

8. Shell Programming and Scripting

Unix Shell basic loop massive n00b

hey guys I would really appreciate some help, i need to do a project for a job that requires minimal UNIX scripting and im REALLY stuck basically Im stuck at what i believe is something really simple but i just dont have a clue how to do it efficiently and properly and i REALLY appreciate some... (16 Replies)
Discussion started by: thurft
16 Replies

9. Shell Programming and Scripting

Shell pipeline help for a n00b

I need to read input from a file, and make sure nothing prints after column 72. basically, ignore input after character 72 until the next newline character. Any help is appreciated. I have been searching forever! (10 Replies)
Discussion started by: Gbear
10 Replies

10. UNIX for Dummies Questions & Answers

FTP EOF n00b Question

Hi folks, can you help me decipher this? I know that ftp will accept input from all commands until it encounters EOF again but I don't quite make sense of what the entirety of the script is really trying to achieve. Many thanks. ftp -n someserver << EOF | head -20 user username@server... (2 Replies)
Discussion started by: verargulla
2 Replies
DBASE_GET_HEADER_INFO(3)						 1						  DBASE_GET_HEADER_INFO(3)

dbase_get_header_info - Gets the header info of a database

SYNOPSIS
array dbase_get_header_info (int $dbase_identifier) DESCRIPTION
Returns information on the column structure of the given database link identifier. PARAMETERS
o $dbase_identifier - The database link identifier, returned by dbase_open(3) or dbase_create(3). RETURN VALUES
An indexed array with an entry for each column in the database. The array index starts at 0. Each array element contains an associative array of column information, as described here: o name - The name of the column o type - The human-readable name for the dbase type of the column (i.e. date, boolean, etc.) o length - The number of bytes this column can hold o precision - The number of digits of decimal precision for the column o format - A suggested printf(3) format specifier for the column o offset - The byte offset of the column from the start of the row If the database header information cannot be read, FALSE is returned. EXAMPLES
Example #1 Showing header information for a dBase database file <?php // Path to dbase file $db_path = "/tmp/test.dbf"; // Open dbase file $dbh = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '$db_path'."); // Get column information $column_info = dbase_get_header_info($dbh); // Display information print_r($column_info); ?> PHP Documentation Group DBASE_GET_HEADER_INFO(3)
All times are GMT -4. The time now is 08:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy