- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell script challenge regarding background/prompt...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:41 AM
12-18-2003 01:41 AM
Anway, points for the genius who can make sense of the quagmire of concepts involved scripting the equivalent of pressing return at the end of a command which runs in background.
I need to run a script to start up a program after Omniback finishes a backup. We do this all the time here, but this time the program runs in background and the script doesn't return the prompt (return code?) therefore omniback thinks the script has failed when it eventually reaches it's timeout.
Running the script interactively I can see that it's kicked off the background process, e even echoes stuff which I stuck in AFTER the bg process. However, it doesn't give me the prompt back until I press return.
So, if I could send "^M" or echo "" or something similar, then connect it to the offending program with a pipe or "<" or something, I'd be in business.
I've looked up googlegroups and found some interesting discussions, but nothing which addressed my problem (either directly or indirectly).
I've tried stuff like:
echo ^M | nohup EXECUTABLE &
( echo ^M | nohup EXECUTABLE & )
echo "" | nohup EXECUTABLE &
echo "" | (nohup EXECUTABLE ) &
nohup EXECUTABLE & < echo ""
nohup EXECUTABLE & | xargs echo ""
I'm gonna be left with no choice but to take this bit o' background code out of the post-exec Omniback script and instead put it in a separate cron-job. This is untidy and not what I really wanna settle for.
So, I've come here... To the Great Source of all Knowledge and Wisdom!
cheers,
Kevin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:47 AM
12-18-2003 01:47 AM
Re: shell script challenge regarding background/prompt/pipe
nohup EXECUTABLE
where tmpf contains an empty line?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:47 AM
12-18-2003 01:47 AM
Re: shell script challenge regarding background/prompt/pipe
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:50 AM
12-18-2003 01:50 AM
Re: shell script challenge regarding background/prompt/pipe
omnibackpostexec script would do soemthing like this
nohup script2 &
exit 0
If you really want to go mad you need to fork and exit and for that, lets do perl.
Your omniback post exec script would look like
#!/usr/bin/perl
$PID=fork;
if($pid != 0){
exit 0;
}
`/my/shell/script/here`;
Of course, if you fancy doing your script in perl, then you don't need to run that shell script at the bottom.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 01:56 AM
12-18-2003 01:56 AM
Re: shell script challenge regarding background/prompt/pipe
Mark, tried the first suggestion, still no-go. I'd be interested in trying a fork in shell script, but don't really wanna use perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 02:03 AM
12-18-2003 02:03 AM
Re: shell script challenge regarding background/prompt/pipe
I don't think you can "fork" in a shell but A.Clay Stephenson is dropping his scripting bombs again today so he may well prove me wrong!
Your problem is not the second command (though if it were written correctly you wouldn't have this problem) but the shell that is running it. This is why I can't quite understand why the first option I suggested doesn't work.
However, that perl thing will do nicely as an omniback post exec script (I do something similar myself) and you'll never have to touch perl aain if you didn't want to :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 02:04 AM
12-18-2003 02:04 AM
Re: shell script challenge regarding background/prompt/pipe
nohup (EXECUTABLE << EOF
EOF) &
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 02:09 AM
12-18-2003 02:09 AM
Re: shell script challenge regarding background/prompt/pipe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 02:18 AM
12-18-2003 02:18 AM
Re: shell script challenge regarding background/prompt/pipe
Thanks everyone. Maybe i'll try the perl option afterall... back soon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 02:24 AM
12-18-2003 02:24 AM
Re: shell script challenge regarding background/prompt/pipe
####################
EXECUTABLE:
#!/sbin/sh
do_something << EOF
EOF
#######################
nohup EXECUTABLE &
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 02:26 AM
12-18-2003 02:26 AM
Re: shell script challenge regarding background/prompt/pipe
Unless you know which fd this is, or have the patience to keep trying
nohup EXECUTABLE 3nohup EXECUTABLE 4
etc up to 20,
then I'd give up if I were you...
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 09:44 PM
12-18-2003 09:44 PM
Re: shell script challenge regarding background/prompt/pipe
mkfifo fifo
nohup EXECUTABLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 09:49 PM
12-18-2003 09:49 PM
Re: shell script challenge regarding background/prompt/pipe
i think
echo > fifo
would be better than
echo "^M" >fifo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2003 12:35 AM
12-19-2003 12:35 AM
Re: shell script challenge regarding background/prompt/pipe
How about posting this script so that we can have a look at it?
JL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2003 01:12 AM
12-19-2003 01:12 AM
Re: shell script challenge regarding background/prompt/pipe
Thanks everyone, but I think I'll just have to use cron to restart this bit and keep it out of Omniback post-exec alltogether.
cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2003 01:51 AM
12-19-2003 01:51 AM
SolutionIf you are just trying to answer a prompt that the application requires, and it's a carriage return, I've done it as such:
echo "\013" | APPLICATION > /dev/null 2>&1 &
This works for me in a script that runs an Informix backup procedure, which is normally interactive.
Regards,
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2003 02:03 AM
12-19-2003 02:03 AM
Re: shell script challenge regarding background/prompt/pipe
cheers Mark!
(I can always count on ITRC Geniuses)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2003 03:09 AM
12-19-2003 03:09 AM
Re: shell script challenge regarding background/prompt/pipe
I just want to say I enjoyed reading this puzzle...
We need more posts like this to test our brains power.
I personally troll the boards to educate myself... and posts like this are helping.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2003 11:43 PM
12-22-2003 11:43 PM
Re: shell script challenge regarding background/prompt/pipe
1st: You start the background job:
bgjob 2>&1 1>logfile |&
2nd: You retrieve the background job's stderr output (error messages, prompts, etc.):
read -p $bg_output
3rd: You send data to the background job's stdin:
bg_input="some_input"
print -p -R $bg_input
This works with POSIX-compatible shells, e.g., /usr/bin/sh and /usr/bin/ksh, but not with bash.
I hope this is useful for you.