Hi I am new to shell scripting. I am using a shell script to create a SQL script file and then call it as well. The created SQL script file has calls to 2 other sql script file, as well as compile and execute a procedure. all this works fine. I am getting some simple errors. My code is as below
Code:
#OBTAINING DATABASE CREDENTIALS
echo -n "Enter the database username: "
read db_user
echo -n "Enter the database password: "
stty -echo
read db_pass
stty echo
echo -n "Enter the database host string: "
read db_host
#OBTAINING THE LOCATION WHERE FILES HAVE BEEN COPIED
echo -n "Enter the location for script files: "
read file_location
#USING THE FILE LOCATION AS INPUT, CREATE THE FILE CONTAINING #THE CALL TO SCRIPTS
echo "spool $file_location/overall_log.log" > newscript.sql
echo "@ $file_location/create_master_table.sql;" >> newscript.sql
echo "@ $file_location/proc1.sql;" >> newscript.sql
echo "begin" >> newscript.sql
echo "proc1();" >> newscript.sql
echo "end;" >> newscript.sql
echo "/" >> newscript.sql
echo "@ $file_location/drop_master_table.sql;" >> newscript.sql
echo "spool off" >> newscript.sql
#EXECUTE THE SCRIPT FILE CREATED. THIS WILL IN TURN CALL OTHER #SCRIPTS,
# COMPILE AND RUN THE PROCEDURE
sqlplus -s ${db_user}/${db_pass}@${db_host} <<EOF
@ $file_location/newnetscript.sql
EOF
exit 0
These are the errros
1.For first few echos: This will display 'Enter the database username' and then the cursor goes to the beginning of the sentence i.e. at 'E'
2. I enter the value(scott/tiger) and then I am getting the error. U can see the overlapping of 'scott' on 'Enter'
scott the database username: ': not a valid identifier4: read: `db_user 'tty: invalid argument `-echo Try `stty --help' for more information. tiger ': not a valid identifier7: read: `db_pass 'tty: invalid argument `echo Try `stty --help' for more information.
....and so on
3. In the later part I am using echo to write to a file named 'netscript.sql'
However the file is created with the name 'netscript.sql?'. Everything else is fine. Only '?' is the problem.
Please help. Also any suggestion for improvement is also appreciated.
I am very new to the world of Unix, in the middle of a crash course as I write this due to a system failure for my company. This system went down approximately 24 hours ago due to some apparent thunderstorms that passed through. The problem is that my company, like many others, has laid off... (5 Replies)
$ errpt | more
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR
B8113DD1 ... (0 Replies)
$ errpt | more
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR
B8113DD1 ... (2 Replies)
Hi all, dummy here.... I have major errors on entering the shell. On login I get:
-bash: dircolors: command not found
-bash: tr: command not found
-bash: fgrep: command not found
-bash: grep: command not found
-bash: grep: command not found
-bash: id: command not found
-bash: [: =: unary... (12 Replies)
So in my shell i execute:
{ while true; do echo string; sleep 1; done } | read line This waits one second and returns.
But
{ while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly.
I have tried this in bash as well as zsh,... (2 Replies)
Bit of a weird one i suppose, i want to use an echo inside an echo... For example...
i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos...
echo "echo "hello"" >$file
echo "echo "goodbye"" >$file
... (3 Replies)
echo `echo ` doesn't echoes anything. And it's logic. But
echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo"
(too much echoing :P):o (2 Replies)
I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here.
I have following script (called out_to_streams.csh):
#!/bin/tcsh -f
echo Redirected to STDOUT > /dev/stdout
echo Redirected to... (2 Replies)
Hi guys,
Been messing around with shell programming for a couple of days and I found something that was pretty odd in the behavior of the echo command. Below is an example-:
When I type the following in my /home directory from my lxterminal in Debian-:
echo "`ls -l`"
I get the... (2 Replies)
Discussion started by: sreyan32
2 Replies
LEARN ABOUT OSF1
script
script(1) General Commands Manual script(1)NAME
script - Makes a transcript of terminal session
SYNOPSIS
script [-a] [file]
The script command makes a transcript of everything printed on your terminal.
OPTIONS
Appends the transcript to file rather than writing it to file.
OPERANDS
The name of an output file that will contain the transcript of the session. If this parameter is omitted, the file typescript is written.
DESCRIPTION
The transcript is written to file, or appended to file if the -a option is given. If no file name is given, the transcript is saved in the
file typescript.
The script ends when the forked shell exits.
This program is useful when you are using a CRT and want a hard-copy record of the dialog (for example, a technical writer might create an
example of a working session this way).
If you specify the -a option and the file does not exist, it is created.
If you do not specify the -a option and the file exists, it is replaced.
RESTRICTIONS
The script command requires a streams based terminal. In single user mode, streams may not be enabled. Under these circumstances, script
will exit with no action. If you are the superuser and need to run this command in single user mode, use the following special instruc-
tions.
Enabling Streams
If it is necessary to enable a streams environment in the single user mode, enter the command /sbin/init.d/streams. This command is avail-
able to the superuser only.
SEE ALSO
Commands: autopush(8), cat(1), echo(1), strsetup(8), tee(1)
System Administration
script(1)