Isn't a shell found on a beach? Need help nesting if's or loops.
As of a week ago i thought a shell was somthing found on a beach.
I'm a virgin when it comes to scripting and i'm having a really bad time here.
What i need to do is prompt for a group number
grep the /etc/groups to get the GID and name
if it exists i want to prompt the user for comfirmation to add user to the group (the other part of the script...thats working) while dispalying the group name and id.
if not i want to promt the user to make a group with name and id supplied by user input via promts.
As of a week ago i thought a shell was somthing found on a beach....
Sorry for being such a noob.
That you've managed to get this far in a week is very much not noob'ish, good progress
What you have looks to be about right, but as vbe says, you've got a typo in there. It looks like you've also introduced a '1' character in that same line, was that deliberate?
As an aside, when comparing two variables in shell scripts, it's a lot safer to use the form:
That way, if one of the variables is zero length, you won't have the script fail with a syntax error.
I don't think you need to do all that checking that the gid they provide matches the group found by grep...
I'd also suggest cleaning up some of your variable assignments, things like reading to INPUT, then immediately assigning it to TEMPIN is somewhat of a waste really.
My go at the problem:
(Untested)
For the next bit of logic (you say you've already got the group create / username add bit working?) I'd do this:
I have a script to start/stop/restart the tomcat application. When we run the script first time i.e stop/start it set all env variables(DISTRIB_ID,NAME,TOMCAT_CFG,....etc),but when we restart the tomcat it is running in the same shell.....I need to set the variables when i restart the tomcat(in the... (1 Reply)
Hi I have the following Korn script having multiple for loops.
#!/bin/ksh
EXPECT=/usr/local/bin/expect
exp_internal
for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 i22 23 24 25 26; do
for i in 01 02 03 04 05 06 07 ; do
for h in 00 01 02 03 04 05 06 07 08 09 10 11 12... (2 Replies)
Hi Guys-
I'm trying to write a script which takes date as input (mm.yy.dd) and search in the current file. If pattern doesn't exist it will then look in a backup directory and so on.
being a newb i'm unable to loop over to the backup directory. hoping for some ideas, i've highlighted the... (1 Reply)
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:
"Create a shell script that changes the selected word to another word in all files from selected archive. The... (1 Reply)
Hi,
#!/bin/ksh
$v=""
for ((i = 1 ; i <= 5 ; i++ ))
do
v="THerrFile_$i.err";
grep -i "$i:Error" $v >>oraerror_output.txt
done
My requirement is to dynamically create variable like
THerrFile_1.err,THerrFile_2.err etc.
where my grep needs... (5 Replies)
Hello All,
I have another Korn shell question. I am writing a script that will ftp a file from my production database to my test database.
To this, I have to construct a loop that checks a specified folder for a file.
If the file exists, I want it execute the ftp protocol and then exit. ... (2 Replies)
Hi!
Can anyone tell me what went wrong in my shell script?
for dt_val in `cut -f 1 -d '|' /prod/ods/satyaki/sqlldr/grp.dat`
do
echo $dt_val
done
And, the output is -
23
39 (7 Replies)
Hi guys,
i need to script the sending of multiple files through one ftp session. I have done this so far:
----------------------------------------------------------------
#!/bin/sh
USER=myuser
PASSWD=mypass
filenum=$1
x=0
ftp -n 159.167.95.199 <<SCRIPT
user $USER $PASSWD
binary
while ... (4 Replies)