Sponsored Content
Homework and Emergencies Homework & Coursework Questions brand new user!.. Lost on BASH script writing Post 302520512 by Byrang on Saturday 7th of May 2011 09:07:44 PM
Old 05-07-2011
brand new user!.. Lost on BASH script writing

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:
I have just gotten into writing bash scripts for a class, part of the assignment is to read and be able to tell what a script does by looking at it, unfortunate for me this is an online class, no real instructor support, so I have no idea what I'm looking at


2. Relevant commands, code, scripts, algorithms:

Code:
#!/bin/bash
if false then
echo "1"
elif true

then
echo "2"
else
echo "3"
fi


3. The attempts at a solution (include all code and scripts):
Brand new user, trying to decipher what this script is supposed to do?


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Tarrant County Community College, North Richland Hills, TX, USA, Steve Smiley (professor), Course # ITSC 1407
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by DukeNuke2; 05-08-2011 at 05:43 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problems writing bash script to unzip files

I'm getting the following errors when I try to write a script to unzip some zip files. When I use the free trial copy of the commerical winzip program, however, they work fine. When I use -l or -t on unzip it indicates no errors. When I use the -o switch interactively from the bash command line it... (1 Reply)
Discussion started by: siegfried
1 Replies

2. Shell Programming and Scripting

Writing Bash script

Could anyone help me to Write a script in BASH Shell to determine the percentage of system disk space you are using. (1 Reply)
Discussion started by: boris
1 Replies

3. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

4. Shell Programming and Scripting

Help with writing simple bash script

I want to write a bash script to: 1. Send an email from localhost to an external gmail account. (gmail then automatically forwards the message back to a pop account on the same server. 2. Script waits 3 minutes then checks to see if the email arrived, and if not, it sends an email to... (9 Replies)
Discussion started by: sallyanne
9 Replies

5. Shell Programming and Scripting

Writing a bash script using host

Im trying to write a script using the host command but its not working properly. I cant understand what Im doing wrong. When I use it at the command prompt, it works fine. But its being used actually in the script, it says its not found: 2 SERVFAIL. Can anyone help me? Here's what I have so far: no... (6 Replies)
Discussion started by: relsha
6 Replies

6. Shell Programming and Scripting

Mkbootfs writing to stdout in bash script

Hi, I need to automate some repacking tasks of a boot image for Android When in command line, I can use this command: mkbootfs /path/to/root > /path/to/ramdisk-recovery.cpio;However, if I try to run the command from a shell script under Ubuntu, it fails and outputs to stdout instead of the... (27 Replies)
Discussion started by: Phil3759
27 Replies

7. Shell Programming and Scripting

Question about writing a bash script

Hello, I want to write a bash script to delete the content after '#'. However, if '#' appears in a string with "", ignore this. For example, input file: test #delete "test #not delete" Output file: test "test #not delete" Does anyone know how to write this script? Thanks (1 Reply)
Discussion started by: jeffwang66
1 Replies

8. Shell Programming and Scripting

Why commands inside bash script lost effectiveness?

Hi, I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment. For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Discussion started by: hce
4 Replies

9. Shell Programming and Scripting

Writing hive scripts in bash script file

Hi, I wanted to load data from HDFS to HIVE by writing bash script. Description: I have written a bash script to validate the data and loaded validated data from local file system to HDFS. Now in the same bash script i wanted to load the data from HDFS to HIVE. How can i do it ? Also how tyhe... (2 Replies)
Discussion started by: shree11
2 Replies

10. Shell Programming and Scripting

Writing Hbase and pig scripts in the bash script file

Hi, I have a script file where i'm validatig the input file and storing the validated records on HDFS. I wanted to load data from HDFS to HBASE using pig script. So for that i have created a HBASE table and written pig script to load data from HDFS to HBASE which is working fine. Now i wanted... (0 Replies)
Discussion started by: shree11
0 Replies
MKTEMP(1)						    BSD General Commands Manual 						 MKTEMP(1)

NAME
mktemp -- make temporary file name (unique) SYNOPSIS
mktemp [-dqu] [-p tmpdir] {-t prefix | template ...} DESCRIPTION
The mktemp utility takes each of the given file name templates and overwrites a portion of it to create a file name. This file name is unique and suitable for use by the application. The template may be any file name with some number of 'Xs' appended to it, for example /tmp/temp.XXXX. The trailing 'Xs' are replaced with the current process number and/or a unique letter combination. The number of unique file names mktemp can return depends on the number of 'Xs' provided; six 'Xs' will result in mktemp testing roughly 26 ** 6 combinations. If mktemp can successfully generate a unique file name, the file is created with mode 0600 (unless the -u flag is given) and the filename is printed to standard output. If the -t prefix option is given, mktemp will generate a template string based on the prefix and the TMPDIR environment variable, if set. The default location if TMPDIR is not set is /tmp. The default location of the temporary directory can be overridden with the -p tmpdir option. The template string created will consist of the prefix followed by a '.' and an eight character unique letter combination. 'Xs' in the prefix string will be treated as literal. If an additional template argument is passed, a second file will be created. Care should be taken to ensure that it is appropriate to use an environment variable potentially supplied by the user. Any number of temporary files may be created in a single invocation using multiple template arguments, also a single one based on the inter- nal template with the -t option value as filename prefix. At least one template argument or the -t option must be present. mktemp is provided to allow shell scripts to safely use temporary files. Traditionally, many shell scripts take the name of the program with the pid as a suffix and use that as a temporary file name. This kind of naming scheme is predictable and the race condition it creates is easy for an attacker to win. A safer, though still inferior, approach is to make a temporary directory using the same naming scheme. While this does allow one to guarantee that a temporary file will not be subverted, it still allows a simple denial of service attack. For these reasons it is suggested that mktemp be used instead. OPTIONS
The available options are as follows: -d Make a directory instead of a file. -q Fail silently if an error occurs. This is useful if a script does not want error output to go to standard error. -t prefix Generate a template (using the supplied prefix and TMPDIR if set) to create a filename template. If -t prefix and template are both given, prefix will not apply to template. -u Operate in ``unsafe'' mode. The temp file will be unlinked before mktemp exits. This is slightly better than mktemp(3) but still introduces a race condition. Use of this option is not encouraged. EXIT STATUS
The mktemp utility exits with a value of 0 on success, and 1 on any failure. EXAMPLES
The following sh(1) fragment illustrates a simple use of mktemp where the script should quit if it cannot get a safe temporary file. TMPFILE=`mktemp /tmp/${0##*/}.XXXXXX` || exit 1 echo "program output" >> $TMPFILE To allow the use of $TMPDIR: TMPFILE=`mktemp -t ${0##*/}` || exit 1 echo "program output" >> $TMPFILE In this case, we want the script to catch the error itself. TMPFILE=`mktemp -q /tmp/${0##*/}.XXXXXX` if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." exit 1 fi SEE ALSO
mkdtemp(3), mkstemp(3), mktemp(3), environ(7) HISTORY
The mktemp utility appeared in NetBSD 1.5. It has been imported from FreeBSD, the idea and the manual page were taken from OpenBSD. BSD
August 15, 2009 BSD
All times are GMT -4. The time now is 08:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy