Sponsored Content
Full Discussion: Simple loop query
Top Forums UNIX for Dummies Questions & Answers Simple loop query Post 302127329 by kutz13 on Tuesday 17th of July 2007 09:22:30 AM
Old 07-17-2007
Simple loop query

Hi All

Just started with shell scripts and am stumped by, what is to most of you no doubt, a simple issue.
All I'm trying to do is prompt a user for input and writing to a log file. If the user types the word 'stop', then the program should halt. If the word typed is 'clear', then the log file should be cleared.

Starting simply(!), all I've got so far is:

LOGDIR=/some/dir/
TARGETFILE="whatever"

ans="abc"

while [ ${ans} != "stop" }
do
echo "Enter text:"
read ${ans}
echo ${ans} >>${LOGDIR}/${TARGETFILE}
done

All that happens is the original value of "abc" is written to the log. Obviously the variable isn't being overwritten by the user input. Can anyone help with basic help for a newbie?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

simple sed query

hi, i would like to replace a string in a series of files with another string, without outputting to new files. is this possible? i've tried using sed, and started by trying to alter the contents of one file... sed 's/string1/string2/g' file.txt but while this does the replacement on... (2 Replies)
Discussion started by: schmark
2 Replies

2. Shell Programming and Scripting

A simple query on unix shell script

I want to write a script to go to particular path in file and run shell script from there. what will be shell script for the same. (2 Replies)
Discussion started by: shekhar_ssm
2 Replies

3. Shell Programming and Scripting

Need Help !!! simple query

Dear, I have a alarm text file, containing minor and major alarms, i am intrested in Mojor alarm with its alarm header and next four lines in seperate file.... Can anybody help me with this below is the alarm file output. :SEV="MAJOR": Object-Instance % unit-type % bts nbr % 25 ... (5 Replies)
Discussion started by: Danish Shakil
5 Replies

4. Shell Programming and Scripting

Query regarding for loop.

Filename.txt My First Line My Second Line ::::While Loop::: Program: while read line do echo "$line" done < Filename.txt output: My First Line My Second Line Is it possible to use for loop to get the same output. I have tried executing below code but i get every word of my file... (8 Replies)
Discussion started by: pinga123
8 Replies

5. Programming

A simple C program query ...

Given the following code inside the function ext3_write_super(): (It's there in Linux kernel 2.6.27.59) static void ext3_write_super (struct super_block * sb) { if (mutex_trylock(&sb->s_lock) != 0) BUG(); sb->s_dirt = 0; } The conditional test at if... (2 Replies)
Discussion started by: Praveen_218
2 Replies

6. Shell Programming and Scripting

Query regarding the if loop

Hi friends, One of my shell program(test.ksh) contains the following if loop.Can anyone please explain me how this loop will work The shell script will be executed as test.ksh -d all The value of variables are user=all opt=-d if && then && _del_all_w=1 || _group="${1}"... (1 Reply)
Discussion started by: kavithakuttyk
1 Replies

7. Shell Programming and Scripting

Infinite loop query

I have a script script.shwhich is scheduled to run at 11 AM everyday. # script.sh Code: ./scb_script.sh & unfortunately scb_script.sh is running today in infinite loop as respective files are not available. My question, when script.sh starts running tomorrow, will the old process be... (1 Reply)
Discussion started by: JSKOBS
1 Replies

8. Shell Programming and Scripting

For loop query...

Hi all... I am using a for loop for another part of AudioScope... Consider this code:- for n in {0..100} do if }" = "another_string" ] then break fi done This works perfectly except I am not sure if breaking out of a 'for' loop might cause... (2 Replies)
Discussion started by: wisecracker
2 Replies

9. Programming

Oracle simple SQL query result in: ORA-08103: object no longer exists

Dear community, please help with a query on Oracle. I'm using SQLPlus (but with SQLDeveloper is the same) to accamplish a sinple query like: select count(*) from ARCHIT_D_TB where (TYP_ID=22 OR TYP_ID=23) and SUB_TM like '%SEP%' and CONS=1234This is a very simple query that works perfect until... (5 Replies)
Discussion started by: Lord Spectre
5 Replies

10. UNIX for Beginners Questions & Answers

If loop query

Hi, its getting aborted with below IF loop, can plz guide me what im missing here if || ; then echo "print $APPEND" fi (3 Replies)
Discussion started by: JSKOBS
3 Replies
Authen::Simple::Kerberos(3pm)				User Contributed Perl Documentation			     Authen::Simple::Kerberos(3pm)

NAME
Authen::Simple::Kerberos - Simple Kerberos authentication SYNOPSIS
use Authen::Simple::Kerberos; my $kerberos = Authen::Simple::Kerberos->new( realm => 'REALM.COMPANY.COM' ); if ( $kerberos->authenticate( $username, $password ) ) { # successfull authentication } # or as a mod_perl Authen handler PerlModule Authen::Simple::Apache PerlModule Authen::Simple::Kerberos PerlSetVar AuthenSimpleKerberos_realm "REALM.COMPANY.COM" <Location /protected> PerlAuthenHandler Authen::Simple::Kerberos AuthType Basic AuthName "Protected Area" Require valid-user </Location> DESCRIPTION
Kerberos authentication. METHODS
* new This method takes a hash of parameters. The following options are valid: * realm Kerberos realm. realm => 'REALM.COMPANY.COM' * log Any object that supports "debug", "info", "error" and "warn". log => Log::Log4perl->get_logger('Authen::Simple::Kerberos') * authenticate( $username, $password ) Returns true on success and false on failure. SEE ALSO
Authen::Simple. Authen::Krb5::Simple. AUTHOR
Christian Hansen "ch@ngmedia.com" COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.8 2008-03-01 Authen::Simple::Kerberos(3pm)
All times are GMT -4. The time now is 02:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy