put an interactive script in background after taking input
i am trying to find a way to put an interactive script in the background after taking input from the user
a few test lines i was trying:
date
echo "Enter location"
LOCATION=
read LOCATION
sleep 100
sleep 200
date
for this small example i want the script to as the user for the location. once the location is supplied then it should execute the subsequent commands in the script in the background and return control of the tesrminal to the user.
Take input.. for example a location code
wait (or, submit to background)
After you input, couldn't you just call another script/program (and put that in the background if need be)?
After input of data, to pass data to other program you could:
1) export the variable
2) pass the variable as a parameter
3) write the variable to a file, and read in called program
Perhaps a little more detail on what you are trying to do.
i am trying to find a way to put an interactive script in the background after taking input from the user
a few test lines i was trying:
date
echo "Enter location"
LOCATION=
read LOCATION
sleep 100
sleep 200
date
for this small example i want the script to as the user for the location. once the location is supplied then it should execute the subsequent commands in the script in the background and return control of the tesrminal to the user.
System Shock -- & doesnt work as when i supply the location it gives an error "Execute permission denied", in other words it doesnt read it as the input to the script but a separate command itself
joeyg -- your idea makes sense. but i was looking for something like a single script way of achieving this.
sb008 -- your idea needs manual intervention. i am giving this to a few non-tech folks who will input what they have to. i cant expect them to find the pid and put it in bg, hence the question.
System Shock -- & doesnt work as when i supply the location it gives an error "Execute permission denied", in other words it doesnt read it as the input to the script but a separate command itself
.
If you create a script that takes input and then executes a command and puts it in the background, it works.
Say you touch a file in /tmp named hello, then you take a file name, pass it to a find command, and put that find command in the background...
After you run the script, you hit the enter key, and you get your prompt back while the find command runs in the background. As for the error you are getting, permission denied means you don't have enough permissions to do something, but I can't tell what it is from what you posted.
Another way of doing it, would be to take the input on the command line, rather than a read command, then you can just put the whole thing in the background, like:
Hello, I want to start out by saying that I am fairly new to scripting and am looking for someone that can point me in the right direction.
Basically what I need is a way to run a interactive script that will prompt users with questions weather that be yes/no or a specific answer.. I want to be... (3 Replies)
I was writing a shell script, where i need to run a command through script and then take input from user and later terminate it. i am not sure how to take input in a proper format immediately after a command.
example: below command line is used to import some data in to database (LDAP)... (3 Replies)
Hi All,
Suppose I have a script and inside it I want/need to put it into background. I need the script to not react to SIGHUP signals.
I tried:
#!/bin/bash
echo "" > test_disown
mypid=$$
echo "PID=$mypid"
(
kill -SIGSTOP $mypid
jobs > myjobs
#disown -h <job-spec>
#kill -SIGCONT $mypid
)... (6 Replies)
Hi there,
How do I enter command to the interactive console.
I was able to do it via the first line. What if I have more lines to input into the interactive console from line 3 onwards. Is there a more easier way?
(echo -e "load openvas" ; echo -e "openvas_help") | msfconsole
... (4 Replies)
Hi All,
i am trying to put ls -lRt command to run in the background but it fails.
i continue to get output on screen and didnt get the command prompt right after i put the command in background.
command i am using is
ls -lRt &
i am using bash.
Can someone let me know how to... (6 Replies)
I have script, which need some variable from user and i use below command for this
read
this script works fine while running without background, but when i run this script in background, it ask first variable then immediately it show below error
KSH variable not found
please let me... (1 Reply)
Hi ,
I am a newbie!!!
I want to develop a script for deleting files older than x days from multiple paths. Now I could reach upto this piece of code which deletes files older than x days from a particular path. How do I enhance it to have an input from a .txt file or a .dat file? For eg:... (12 Replies)
I need to run an interactive program in the background so I can grep it for specific data to use for some logic in a script.
There is no quiet or background mode on the program so I plan to redirect a document with commands in it and then to grep the output.
This is almost working, except... (1 Reply)
Hi,
I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database.
For instance:
USER CITY
--------- ----------
A CITY_A
B CITY_B
C ... (2 Replies)
Hi All,
I'm trying to get this to work but when I execute it I get the following error
./ftp_upload.sh: line 78: syntax error: unexpected end of file.
This was working before I expanded the script and had the here document part directly below within a function.
Can anyone spot what I've... (5 Replies)