Shell Scripting (prompt off)


 
Thread Tools Search this Thread
Operating Systems AIX Shell Scripting (prompt off)
# 1  
Old 10-10-2013
Shell Scripting (prompt off)

Dear all experts,
I have a script written to compress a list of files, during compressing, some of the files are having same name. When the compressing started, the same name file will be prompted with message whether to overwrite the old file. I need to enter "y" to continue.
Is there any way I can put into the script so that it will answer "y" for each of the prompted question?
In DOS, as I know can put a prompt off, but I do not know what should I put on Shell Script.
Thanks.
# 2  
Old 10-10-2013
If you refer to tar then this might help:
Code:
tar --help|grep -i over
 Overwrite control:
      --no-overwrite-dir     preserve metadata of existing directories
      --overwrite            overwrite existing files when extracting
      --overwrite-dir        overwrite metadata of existing directories when
                             silently skip over them
  -U, --unlink-first         remove each file prior to extracting over it
      --suffix=STRING        backup before removal, override usual suffix ('~'
                             unless overridden by environment variable

# 3  
Old 10-11-2013
Quote:
Originally Posted by sea
If you refer to tar then this might help:
Code:
tar --help|grep -i over
 Overwrite control:
      --no-overwrite-dir     preserve metadata of existing directories
      --overwrite            overwrite existing files when extracting
      --overwrite-dir        overwrite metadata of existing directories when
                             silently skip over them
  -U, --unlink-first         remove each file prior to extracting over it
      --suffix=STRING        backup before removal, override usual suffix ('~'
                             unless overridden by environment variable

Dear sea,
I am not referring to tar command. I refer to compress command.
For example, I have a file name "aaaa" and I would like to compress it. I will run command "compress aaaa" and it will become aaaa.Z
After that I received another aaaa file again. This time when I perform compress aaaa, the system will prompt me a message as

Do you wish to write over the existing file aaaa.Z?

I have to enter "y" to overwrite the original file.

I would like to know how can I skip the answering "y" in my script so that the above prompt will not appear?
# 4  
Old 10-11-2013
Did you check the -f option ?
Code:
man compress

# 5  
Old 10-11-2013
Quote:
Originally Posted by sea
If you refer to tar
sea, what you quoted from is a Linux man page. This is the AIX board and the AIX tar works quite differently - POSIX-compatibly, that is.

Quote:
Originally Posted by kwliew999
For example, I have a file name "aaaa" and I would like to compress it. I will run command "compress aaaa" and it will become aaaa.Z
After that I received another aaaa file again. This time when I perform compress aaaa, the system will prompt me a message as

Do you wish to write over the existing file aaaa.Z?

I have to enter "y" to overwrite the original file.

I would like to know how can I skip the answering "y" in my script so that the above prompt will not appear?
Even if sea's suggestion was faulty his intention was right: read the man page (of compress, instead of GNU-tar) to find the following:

Code:
        -f or -F
            Forces compression. The -f and -F flags are interchangeable.
            Overwrites the File.Z file if it already exists.


How to use man

As you mentioned DOS i suppose you are not familiar with UNIX in general or AIX in specific. Here is a general advice: if you do not know how to use/configure a command you can always enter

Code:
man command

to get the "man[ual] page" of command. This works even for man itself, so man man will tell you how to use man. The works not only for commands but also standard configuration files. Enter, for instance,

Code:
man filesystems

to get information about the file /etc/filesystems, which denotes all the mountable filesystems in a system.

(Tip: the paginating program used in man is more which navigation keys match the ones of vi. Scroll down a line with "j", scroll up a line with "k", etc..)

If you are not sure which command to use you can search all the man pages for a specific term with the man -k keyword (or its more eponymic alias apropos keyword) command, which will list all the man pages containing keyword.

For instance:

Code:
# man -k users
bellmail(1)     - Sends messagesto system users and displays messages from system users.
chargefee(1)    - Charges endusers for the computer resources they use.
chpasswd(1)     - Changes password for users.
comsat(1)       - Notifies usersof incoming mail.
custom(1)       - Enables usersto customize X  applications.
[...]
# apropos users
bellmail(1)     - Sends messagesto system users and displays messages from system users.
chargefee(1)    - Charges endusers for the computer resources they use.
chpasswd(1)     - Changes password for users.
comsat(1)       - Notifies usersof incoming mail.
custom(1)       - Enables usersto customize X  applications.
[...]

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 6  
Old 10-11-2013
Quote:
Originally Posted by ctsgnb
Did you check the -f option ?
Code:
man compress

TQVM for the parameter "-f". I just keep on digging how to send in a "y" for whatever return on screen. Never in my mind tho of using compress function's parameter.

Thanks.

---------- Post updated at 05:34 PM ---------- Previous update was at 05:29 PM ----------

Dear Bakunin,

Thanks for your detail and helpful hint.
I do know how to use AIX's man. I not familiar with Linux tar. Now only I know tar is something like man in unix.
I was digging the way how to pass a "y" into anything pop up on screen. Never tho of checking function compress's ability.

Anyway, thanks a lot.

Quote:
Originally Posted by bakunin
sea, what you quoted from is a Linux man page. This is the AIX board and the AIX tar works quite differently - POSIX-compatibly, that is.



Even if sea's suggestion was faulty his intention was right: read the man page (of compress, instead of GNU-tar) to find the following:

Code:
        -f or -F
            Forces compression. The -f and -F flags are interchangeable.
            Overwrites the File.Z file if it already exists.


How to use man

As you mentioned DOS i suppose you are not familiar with UNIX in general or AIX in specific. Here is a general advice: if you do not know how to use/configure a command you can always enter

Code:
man command

to get the "man[ual] page" of command. This works even for man itself, so man man will tell you how to use man. The works not only for commands but also standard configuration files. Enter, for instance,

Code:
man filesystems

to get information about the file /etc/filesystems, which denotes all the mountable filesystems in a system.

(Tip: the paginating program used in man is more which navigation keys match the ones of vi. Scroll down a line with "j", scroll up a line with "k", etc..)

If you are not sure which command to use you can search all the man pages for a specific term with the man -k keyword (or its more eponymic alias apropos keyword) command, which will list all the man pages containing keyword.

For instance:

Code:
# man -k users
bellmail(1)     - Sends messagesto system users and displays messages from system users.
chargefee(1)    - Charges endusers for the computer resources they use.
chpasswd(1)     - Changes password for users.
comsat(1)       - Notifies usersof incoming mail.
custom(1)       - Enables usersto customize X  applications.
[...]
# apropos users
bellmail(1)     - Sends messagesto system users and displays messages from system users.
chargefee(1)    - Charges endusers for the computer resources they use.
chpasswd(1)     - Changes password for users.
comsat(1)       - Notifies usersof incoming mail.
custom(1)       - Enables usersto customize X  applications.
[...]

I hope this helps.

bakunin
# 7  
Old 10-11-2013
@ bakjunin: Yes sorry, was just looking at the threads title.
@ kwliew999: No, man is same for both, but tar is like compress.
Sorry for the irritation.

But either way, these kind of commands usualy provide arguments to overwrite (or not) any possible conflicting files.
And terminal commands usualy come along with (sometimes just either one of) these arguments:
Code:
-h
--h
-help
--help

Which i prefer on many occasions, since i can grep for keywords, which i'm not aware to do in manpages.
Helps alot to get quicker to the helpfull 'part'.

Hope this helps
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Scripting password prompt for restarting Jboss application

Hi When I do on console a stop, the script prompts for password > stop_idm_suite.sh Suite system password:Here experct of the shell script stop_idm_suite.sh DoIt() { # prompt System password echo "" ${BMC_JAVA_HOME}/java -Didm.suite.home=${BMC_IDM_SUITE_HOME} -classpath... (1 Reply)
Discussion started by: slashdotweenie
1 Replies

2. Programming

scripting for recieving a prompt

I have to run a script provided by a vendor. Its an executable so I can't change it. basically after I call it it prompts me for a password. The script does not provide a way for me to pass a password with the command that calls the script. I would like to automate running this script from... (5 Replies)
Discussion started by: guessingo
5 Replies

3. Shell Programming and Scripting

Changing the shell prompt

Hi, I want to change the shell prompt, using the cd command. I have a shell prompt like this - p78-mfx(dgaw1078/9781)$ Now i do this - p78-mfx(dgaw1078/9781)$ cd log4j here the shell prompt should change like this - p78-mfx(dgaw1078/9781)log4j$ (6 Replies)
Discussion started by: arunkumarmc
6 Replies

4. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

5. UNIX for Dummies Questions & Answers

how much we can pipe in shell prompt ?

Hi All experts, I was asked some questions of late & i was not aware of these. 1Q. how much we can pipe in shell prompt ?2Q. how many arguments we can pass in shell script & how to print that ? (eg, if i want to know what I passed in 11th Argument) ( for 3rd argument we can do echo $3, but I think... (7 Replies)
Discussion started by: adc22
7 Replies

6. UNIX for Advanced & Expert Users

Weird in Shell Prompt

Hi, I saw something in weird in Shell prompt. I did the following steps 1) Typed ls -l and pressed ESC without entering 2) Typed "v" (please notice that I did not type "i" after "v"), which opened vi editor 3) I see the "ls -l" command that I typed in shell prompt 4) Without modifying... (6 Replies)
Discussion started by: bobbygsk
6 Replies

7. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

8. UNIX for Dummies Questions & Answers

shell specific prompt

currently, I set my prompt in my .cshrc file as: set prompt = "%B%h %m %P %/ \n% " I have to use certain shells for some specific tasks and would like to set different prompts depending on the type of shell that I am using. Any advice? Thanks (3 Replies)
Discussion started by: dranNfly
3 Replies

9. UNIX for Dummies Questions & Answers

prompt in sh shell

Hi, I´m using SCO Unix 5.0.5 and I want to configure de variable PS1, so when I type the command: cd /etc/ the prompt shows /etc/_> Is that possible with sh shell? I´ll appreciate your help. Thanks, a Happy New Year! (1 Reply)
Discussion started by: diegoe
1 Replies

10. UNIX for Dummies Questions & Answers

No shell prompt?

When I login to a specific machine (running Solaris 2.8; actually serveral machines behave this way), with a known good account, I don't get any shell prompt, and no screen responses to various commands such as ID and PWD. Any ideas on what is causing this, and how to change this behavior? (2 Replies)
Discussion started by: Mufasa
2 Replies
Login or Register to Ask a Question