I am a beginner (Just 2 days old ), i will really appreciate if you can solve my silly queries as below:
Lets say i write a script like this
My environment is set to work in tcsh.
My query are:
a) how does placing !/bin/bsh as comment results in its execution as bsh shell? AS i am a beginner, i need to know if it is an exception ? how does placing a path as comment affects the execution of code.
b)If, say i place the path as second line of my comment. assume my first two lines are as below
#just comment
#!/bin/bsh
The code executed, but i also get some errors which says command not found.
c) Is it compulsorily to place "exit 0" at the end of every script? where should it be used?
The "shebang" line is not an ordinary comment (btw do you mean #! /bin/bash)
It instructs the shell that executes the script which interpreter to call on the script when it is the first line of the script.
The value you exit from a script sets $? in the parent shell, this can be used to "report" an error in the running of the script to the parent or to make decisions based on the exit status.
A facile example which checks for the existence of the user in /etc/passwd before running the useradd program.
In the example above the while loop will continue until verified_useradd.sh returns with no error, thus guaranteeing a user has been added (or at least that useradd was called
Hi,
I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database.
For instance:
USER CITY
--------- ----------
A CITY_A
B CITY_B
C ... (2 Replies)
Hi All,
I have made a file file usercreate.sh & it has to run in tcsh env & needs some path to be set.
my script is as below.
##########################
#!/bin/csh
setenv PATH "/usr/lib/java/class"
setenv LD_LIBRARAY_PATH
###########################
but when i am ruuning my script... (1 Reply)
Im trying to make a script that simply adds a word to the last available line in a txt file without overwriting any previous lines.
Ive googled this and there are great examples but no one explain what each function does, and i dont entirely understand how it works.
Basically Im looking for... (7 Replies)
Lets say I wanted to create a script that would show what people are doing on my machine using the w command and refresh in about 6 seconds. What would be the easiest way to do this? I pretty much want the script to loop until I stop it.
I'm using the BASH shell by the way.
Help is appreciated.... (1 Reply)
Hi,
I have a requirement as below which needs to be done viz UNIX shell script
(1) I have to connect to an Oracle database
(2) Exexute "SELECT field_status from table 1" query on one of the tables.
(3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
hi,
I am new script learner,
so my basic doubt is ,
how to store value of any command in a variable example
$ ls | wc -l
i want to stote the output of this in a variable c.
so that i can use c in if else loop.
and when do we use " ` " symbol in script..
can anyone also tell for... (5 Replies)
I everybody!
I am trying to install the bsh shell on a SCO unix and i don't know how.
The deal is that i have an old SCO unix running with an old system made with cobol, so it works with shell menus and it use a variety of a shell called bsh (Business Shell) so i search for a package to install... (5 Replies)
Hi All,
I am new to shell scripting.
I have a variable which holds a numeric value.I have to check whether this variable holds a value between(0- 8),(8-17)(17-24).How do i write this syntax using if in shell scripting.
Thanks
Vignesh (2 Replies)
In a Bourne shell script, I often come across statements involving `sh -c`. I was not able to make out if any reason is there behind that.
example:
echo `sh -c 'date'` killing all server processes
Instead of the above, I can use
echo `date` killing all server processes.
Is there any... (1 Reply)