Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a file from user responses script 1

Status
Not open for further replies.

teakandme

MIS
Jun 10, 2004
57
US
New to Unix scripting....Can someone assist with a script or idea for a script that will read user responses and write them to a file?
 
i don't understand your question. do you mean you want to monitor the user's actions in your system after user sign in?

 
teakandme,

This is one way of doing it :)

Code:
#!/bin/sh

file="output.txt"
cat /dev/null > $file
echo "Whatever you write will go into a file called $file located in the same"
echo "Directory as this script. Type the word exit to end writing"

while read line
do
  if [ $line = "exit" ]
  then
    break
  else
    echo $line >> $file
  fi
done

Regards,
Khalid
 
What happens if "exit" is typed in for another reason? (part of data being entered)?


BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
You can also use script to capture a users keystrokes.

Put

script

at the end of their .profile

you can also use read

echo "What's your name: ........../b/b/b/b/b/b/b/b/b/b/c"
read answer
echo "Hello " $answer

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top