08-04-2007
Frequently Asked Questions for Assgn 3.
What does the .std_dbrc file contain?
Something like:
STD_DBROOT=${HOME}/class/2031/Assgn3/STD_DB
You do not submit this file, I will be using mine that will point to my std_db. But it should work with such a file, otherwise your program will not pass the tests.
Do we need the trailing slash (/) in the STD_DBROOT definition?
Your program should work even if there is no trailing slash. The idea is that two or more slashes are equivalent to one, so it is better if you have two slashes rather than none (disaster).
Can we invoke one of our scripts from within another script?
In principle yes, but it is far safer if you do not unless you know what you are doing. If I were you I would opt for cut and paste.
How do I use the .std_dbrc from within my own script?
You source it. Sourcing is normally just a dot (.).
. ${HOME}/.std_dbrc
If you create this file and it seems lost use
ls -a
Why can't I see my .std_dbrc with ls?
Because files that start with a dot are hidden in Unix/Linux. Use ls -a to see all your files in the current directory. I mostly use ls -ltr or ls -latr, to see the most recent (and thus most relevant files) last (the first one might have scrolled above the screen).
What does it mean to "source" a file?
The manual says:
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell
environment and return the exit status of the last command exe-
cuted from filename. If filename does not contain a slash,
file names in PATH are used to find the directory containing
filename. The file searched for in PATH need not be exe-
cutable. When bash is not in posix mode, the current directory
is searched if no file is found in PATH. If the sourcepath
option to the shopt builtin command is turned off, the PATH is
not searched. If any arguments are supplied, they become the
positional parameters when filename is executed. Otherwise the
positional parameters are unchanged. The return status is the
status of the last command exited within the script (0 if no
commands are executed), and false if filename is not found or
cannot be read.
most of the details there are irrelevant to you, but the thing to keep in mind is that it executes commands from filename in the current shell environment.
Do I need to change the PATH environment variable for this assignment?
NO! You should not change the PATH. In general we do not play with PATH unless we know what we are doing.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello!
I need to read a text file containing certains rows and columns!The following is a sample file with only three rows!
01:41:30:00:05:51 OFF 48506649K 5769415 63494357K
01:41:30:00:05:65 ON 4493546K 27266552 5880264K
01:41:30:00:05:78 OFF 614556K 89121 47291K... (1 Reply)
Discussion started by: sandytul
1 Replies
2. Programming
Please Help me
I have a Bulk file containing Hex data
I want to read specific lines from that bulk file by ID number.
example
ID DATE Time data
14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223... (10 Replies)
Discussion started by: rajan_ka1
10 Replies
3. Shell Programming and Scripting
Is anyone able to help with writing a program that will do the following:
1. Read the contents of a file, line by line, and on each line, assign each of the two columns to a shell variable.
2. perform an action on the variables
3. Read the next line.
Here is what I've gotten so far. ... (3 Replies)
Discussion started by: akbar
3 Replies
4. Shell Programming and Scripting
I am having one text file and i need to read that data from my shell script.
I will expain you the scenario:
Script look like:
For name type 1:
For age type 2:
For Salary type3:
echo "Enter the input:"
read the data
if input is 1 then go to the Text file and print the... (2 Replies)
Discussion started by: dineshmurs
2 Replies
5. Shell Programming and Scripting
I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Discussion started by: raj100
3 Replies
6. UNIX for Dummies Questions & Answers
Hi Guys,
Please help me with my problem here:
I have a source file:
1212 23232 343434 ASAS1 4
3212 23232 343434 ASAS2 4
3234 23232 343434 QWQW1 4
1134 23232 343434 QWQW2 4
3212 23232 343434 QWQW3 4
and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies
7. UNIX for Dummies Questions & Answers
sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies
8. UNIX for Beginners Questions & Answers
hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line.
Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies
9. Shell Programming and Scripting
I have input data looks like this which is a part of a csv file
7,1265,76548,"0102:04"
8,1266,76545,"0112:04"
I need to make the output data should look like this and the output data will be part of text file:
7|1265000 |7654899 |A|
8|12660000 |76545999 |B|
The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies
10. Shell Programming and Scripting
i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
Discussion started by: Gurdza32
11 Replies
DOT(1P) POSIX Programmer's Manual DOT(1P)
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond-
ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
NAME
dot - execute commands in the current environment
SYNOPSIS
. file
DESCRIPTION
The shell shall execute commands from the file in the current environment.
If file does not contain a slash, the shell shall use the search path specified by PATH to find the directory containing file. Unlike nor-
mal command search, however, the file searched for by the dot utility need not be executable. If no readable file is found, a non-interac-
tive shell shall abort; an interactive shell shall write a diagnostic message to standard error, but this condition shall not be considered
a syntax error.
OPTIONS
None.
OPERANDS
See the DESCRIPTION.
STDIN
Not used.
INPUT FILES
See the DESCRIPTION.
ENVIRONMENT VARIABLES
See the DESCRIPTION.
ASYNCHRONOUS EVENTS
Default.
STDOUT
Not used.
STDERR
The standard error shall be used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
Returns the value of the last command executed, or a zero exit status if no command is executed.
CONSEQUENCES OF ERRORS
Default.
The following sections are informative.
APPLICATION USAGE
None.
EXAMPLES
cat foobar
foo=hello bar=world. foobar
echo $foo $bar
hello world
RATIONALE
Some older implementations searched the current directory for the file, even if the value of PATH disallowed it. This behavior was omitted
from this volume of IEEE Std 1003.1-2001 due to concerns about introducing the susceptibility to trojan horses that the user might be try-
ing to avoid by leaving dot out of PATH.
The KornShell version of dot takes optional arguments that are set to the positional parameters. This is a valid extension that allows a
dot script to behave identically to a function.
FUTURE DIRECTIONS
None.
SEE ALSO
Special Built-In Utilities
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE
/The Open Group 2003 DOT(1P)