E-Mail:

How do I re-redirect stdin in a Unix or Linux shell script?

Hi Dave. I’m trying to create a shell script in HP-UX Unix that looks like this:

while read usrname
 do
   lsh $usrname
 done < $file

and in lsh I added some error checks. If one occurs I ask the user to correct their input, but the code didn’t work that way and it continues to read another line from file usrname. I don’t know how to stop in while loop, to get input from the user. What’s the trick?

This is a classic shell scripting question because once you redirect standard input to be from a file (as you do with the < $file after the done statement) then subshells, functions and everything else also inherit the changed file descriptor.

The good news is that the solution is straightforward: just…

One Comment

Automation of submittion of password through shell script without prompting for password in HPUX os.

What Do You Think?

 

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense your hard-earned information back to the community, get involved in our community site today! You can write about anything - no matter the topic. Exceptional candidates will be offered the chance to contribute to (and generate revenue from) the main Lockergnome site. Join us today!

Tip - Nov 28, 2007

Quick Tip - Getting Started With GIMP

71 queries / 0.182 seconds.