so for the purposes of this thread, interactive scripts are shell scripts that prompts for a response from a user and then waits for the user to enter a response before proceeding.
now, from my understanding of this, the one common string i can expect to find in all interactive scripts is some variation of this:
notice i bolded the "read -p".
the reason i'm asking about this is, i need to add a line to every line that contains the pattern "read -p" or any other pattern that can be used to identify interactive scripts.
the line i need to add after every line that identifies a script as interactive should be:
below is command im using:
Question:
1. Also, are there any other patterns I can look for to help me identify if a script is an interactive script?
There are an unlimited number of patterns you could look for that are common to all POSIX conforming shells. There are others that are specific to specific shells. There are others that are specific to certain versions of certain shells.
Adding the line you say you want to add in the place you say you want to add it will be a syntax error in many cases. You CAN NOT add fixed text in a fixed position after a prompt is written and a response is read without fully understanding the context of the code in question. For example:
will not work if you insert your new statement after the while before the do.
Note also that most of the code you could be used to produce prompts in an interactive script can, with appropriate file redirections, be used in a non-interactive script with the prompt being redirected to a log file and the response being read from a configuration file.
Note also that interactive programs can be written in C, C++, FORTRAN java, awk, and hundreds of other programming and scripting languages; and sticking shell code into the middle of an object file or into the source of an interactive program that is not a shell script will not work.
This User Gave Thanks to Don Cragun For This Post:
morning,
i introduce the following sentence:
"sudo lsof -i | grep smtp"
ang get a list of the processes. two of them i don't know what is the function: 29574 & 29575, with the following indication: "memo" the rest of the processes shown are smtpd. i kill these two processes and they disappear,... (4 Replies)
i have to run the following script through a pipe:
script.sh:
#!/bin/bash
echo "Hello World"
echo -e "The \033
here's how its currently being run:
bash -c "$(cat script.sh)"
This is an interactive script. the problem is, when i run it this way, if you go to another terminal and... (4 Replies)
I'm writing a basic ldapsearch script that prompts the user for their search criteria. The input they're being asked for is the search filter portion of the ldapsearch command. This string must be quoted. When the script executes the command it returns nothing. If I hard code a search filter it... (1 Reply)
Dear Members,
I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc.
I would like to create a script which will will call other scripts based on the request action.
Can we directly read from the REQUEST_ACTION... (2 Replies)
Hello friends,
I am a ORACLE user, we have some internal database file, lets say "demo.config" and an internal tool to patch this file....lets call that tool as "dbfixer".
We have 100's-1000's of such files "demo.config" which need to get patched by the tool. So we need to write a script ...... (1 Reply)
Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines.
It then prompts for deletion of the file.
If user supplies arguments with the script , then it works on those files... (8 Replies)
Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines.
It then prompts for deletion of the file.
If user supplies arguments with the script , then it works on those files... (1 Reply)
Hi all,
I am trying to write a program that will automate interactive scripts that use 'pkgadd'. Easily enough I can use 'pkgask' and a response file for most of what I want to do, but unfortunately there are parts of some pkg installations that are configured to only take input from /dev/tty!!... (2 Replies)