Auto Answer Commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Auto Answer Commands
# 1  
Old 03-03-2010
Auto Answer Commands

I'm trying to script out the following commands;

newfs
ufsdump
ufsrestore

All of these commands ask me to continue.


ufsrestore asks
Code:
set owner/mode for '.'? [yn] y
Directories already exist, set modes anyway? [yn] y


newfs asks
Code:
newfs: construct a new file system /dev/rdsk/c1t1d0s0: (y/n)? y


I've skimmed over the man files, and I do not see a silent option.

I'm hoping there is something simple that I am missing.

Thanks in advance!
# 2  
Old 03-03-2010
If you want to give yes,you change 'y' in the following script.If you want to give no,then you change 'n' in the following script.I tested the script with
rm -i option which will ask user confirmation before removing the file.

Code:
echo "y" | newfs
echo "y" | ufsdump
echo "y" | ufrestore

NOTE:You try this.Because,in my environment,the above commands aren't working.But,I tested this rm command with -i option.
# 3  
Old 03-03-2010
Hi.

Have a look at the yes command.

Or if it's not that simple, you can put your responses in a file, like:

Code:
$ cat Test
read a
read b
read c

echo a is $a
echo b is $b
echo c is $c

$ cat response
y
n
y

$ cat response | ./Test
a is y
b is n
c is y

# 4  
Old 03-03-2010
newfs worked

The echo "y" | newfs worked.

However,

Code:
echo "y" | ufsdump of - / |(cd /mnt; ufsrestore xvf -)

Did not. Is this possibly due to the extra pipe at the end for |(cd /mnt; ufsrestore xvf -) ?

Just for the heck of it, I also tried
Code:
echo "y" | (ufsdump of - / |(cd /mnt; ufsrestore xvf -))

with full failure.

Thanks.

---------- Post updated at 04:12 AM ---------- Previous update was at 03:23 AM ----------

I'm not to sure if I have the syntax right, but both of the following failed
Code:
yes y | ufsdump of - / |(cd /mnt; ufsrestore xvf -)
yes "y" | ufsdump of - / |(cd /mnt; ufsrestore xvf -)

As far as the script that you have mentioned, I'm not to sure how I can incorporate the answers with the commands that I am using.
Code:
set owner/mode for '.'? [yn] y
Directories already exist, set modes anyway? [yn] y

Where would I insert the $a? I can't echo it. I can't place it on a separate line or it one initiate until the first command is over. ufsdump/ufsrestore

I tried:
Code:
ufsdump of - / |(cd /mnt; echo "y" | ufsrestore xvf -)

but it doesn't work due to a "Broken Pipe"

Anymore suggestions?
# 5  
Old 03-03-2010
Slightly off topic.
Quote:
ufsdump of
Are you sure about the "o" switch? Maybe it should be a zero.

Btw. If you are trying to clone a root partition there are warnings in the Solaris 10 ufsdump manual about dumping an active mounted filesystem.
# 6  
Old 03-04-2010
The command works.

I just need a way to answer the questions presented by the ufsdump/ufsrestore line.

Quote:
Btw. If you are trying to clone a root partition there are warnings in the Solaris 10 ufsdump manual about dumping an active mounted filesystem
I'm aware of the risks. But this isn't my problem at hand.

---------- Post updated at 11:09 PM ---------- Previous update was at 08:17 AM ----------

Any ideas?
# 7  
Old 03-04-2010
Firstly, sorry that I didn't reply sooner... but no! I've tried all manner of pipes, redirections and playing with file descriptors, but to no avail.

I even found some perl (from the OpenSolaris website) that proclaimed to address the "issue", but that didn't work.

What happens if you run it from cron? That's not connected to a terminal. Would it just give up or continue.

Still thinking Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Howto auto boot SPARC | How to auto supply "start /SYS" and "start /SP/console" commands

When I power ON my T4-1, I got a prompt -> where I have to start /SYS and start /SP/console. How can I auto supply these two commands ? (3 Replies)
Discussion started by: z_haseeb
3 Replies

2. UNIX for Beginners Questions & Answers

Answer the qs in UNIX commands

1) whats the output of the below script, when executed at the command line vi test.ksh echo 'output $@:'$@ echo 'output$#:'$# ---------------- cmd execution as follows $test.ksh Hello" a)output $@:1,output $#:Hello b)output $@:Hello,output $#:1 c)output$@:,output $#: d)None of the... (4 Replies)
Discussion started by: balaji23_d
4 Replies

3. Shell Programming and Scripting

Auto answer option in scripting.

Hi masters, How to get auto answer option in scripting. for example in my script i uses the gpg command , in that beginning it will ask passpharse : ( in that i need to type my passpharase) and once i typed it will ask Use this key anyway? ( for that answer will be yes) for... (1 Reply)
Discussion started by: anishkumarv
1 Replies

4. UNIX for Dummies Questions & Answers

I welcome all to answer my Q's

Hi everyone,, I am new to the forum...but not to Unix. I have gathered few questions from my mates who attended interviews in various companies as I have to attend one on dec 3rd for Sys admin position. Please respond with the answers you know and also help with various other interview... (2 Replies)
Discussion started by: impawan
2 Replies

5. Shell Programming and Scripting

help me to answer this

Hello everyone I update my question. Thanks for your reply joeyg If I type the last command and send to a text file. I get this last >usuarios.txt root pts/0 160.40.35.277 May 22 11:08 still logged in. root pts/0 alopez02 May 22 09:23 - 10:11 (00:47) root pts/0 160.40.35.277 May 20... (0 Replies)
Discussion started by: lo-lp-kl
0 Replies

6. UNIX for Dummies Questions & Answers

Answer them if u can...

Try to answer these questions on Unix: 1.what will be the segment() function do? 2.How Unix is more powerful than Windows? 3.Where ownership details will be stored of a particular file in Unix? 4.State different uses of ^ symbol in regular expressions. 5.What does export command used for?... (5 Replies)
Discussion started by: dreambig
5 Replies

7. Solaris

Can anybody answer this.....

Hi i am trying the threads concept in unix environment using C... but i am getting error of "wait_fd: Couldn't find procinfo for fd 24"... what does this error mean..... help me in solving this issue... Thanks in advance shivamasam (3 Replies)
Discussion started by: shivamasam
3 Replies

8. Programming

can any one answer ????

Q.1 Diffrence between terminal and pseudo-terminal ? Q.2 What is terminal login ? What is a netwok Login ? Q.3 What is meant by baud rate of a terminal ? Q.4 which structure is used for job control in Unix/Linux ?and where these structure are means in which directory ? (2 Replies)
Discussion started by: mobile01
2 Replies

9. UNIX for Dummies Questions & Answers

already found the answer

Hi folks, I Got a little question here, When i try to start a telnet session to my unix server, the unix server states the following message: telnetd: All network ports in use. Connection closed I know it has something to do with pseudo tty's? I've tried to search the... (3 Replies)
Discussion started by: Erik Rooijmans
3 Replies
Login or Register to Ask a Question