I have two BASH shells and would like to send data from one to the other. To achieve this, I have thought the following:
1) Shell #1 runs a script in order to create the file "output.out" with the data.
2) Meanwhile Shell #2 is waiting for "output.out" is created for starting with a second script later.
My question is: when "output.out" is created, how can I send an event to Shell #2 so it can start with the second script?
I tried this:
While Shell #1 is running, Shell #2 is executing this script:
But since I'm doing a heavy simulation, I cannot use this solution! What I need is to send an event to Shell #2...
Put your logic into a function, which gets called by trap when you send a SIGUSR. In the main body, run an infinite loop that just idles along. From your first script, send the signal using kill as soon as output.out has been created.
You could create a named pipe and use that to communicate between the two. Create the file mkfifo pipe_name, with one shell, cat some_file > pipe_name. It will appear to hang, with second shell, cat pipe_name and the output will be displayed and the first shell will complete.
Now with the second shell, cat pipe_name, this will appear to hang. With the first shell, cat some_file > pipe_name. The output will be displayed in the second.
Thanks a lot peterro! Definitely this is the best and clear way to do it! But now I have another question... what to do if I don't want to display the file content on the shell?
Many thanks in advance!
----
PS: Thanks pludi for your reply!... sorry for the ignorance (as you can see, I'm a beginner in the unix universe)... you say: "run an infinite loop that just idles along"... if I do an infinite loop, it will force the processor, isn't it?
Thanks in advance!
----
---------- Post updated at 03:56 PM ---------- Previous update was at 03:52 PM ----------
Thanks pludi for your reply!... sorry for the ignorance (as you can see, I'm a beginner in the unix universe)... you say: "run an infinite loop that just idles along"... if I do an infinite loop, it will force the processor, isn't it?
Yup. It's just like reading/writing to any typical flat file. The named pipe just has some useful properties for purposes such as this. See Chapter 14 in Expert Shell Scripting (Apress)
In shell scripting, TestEmail is an existing group email. I am using the below command to send emails who are existed under TestEmail . Unable to receive the email. I have tried group ="id1 id2 " .Its working and i tried creating alias as well.
Can we do it without creating alias or group ="id1... (1 Reply)
Hello experts!
I have a file1 with the following format (yr,day, month, hour,minute):
201201132435
201202141210
201304132030
201410100110
...
What i want to do is to assign variables and then use them in the curl command to download the text of each event from a web page.
What I have... (6 Replies)
I need a script to keep polling "receive_dir" directory till "stopfile" get written in the directory.
This has to run despite empty directory.
So far i have this but fails if receive_dir is empty with no files with "unary operator expected". Help !!
#!/usr/bin/ksh
until
do
for i... (1 Reply)
Hi
I'm new to scripting - please help me...
I'm trying to run a script written by a friend:
#!/bin/bash
for aStat in ....
do
....
done
when coping the script to the terminal I get:
/bin/bash: Event not found.
for: Command not found. (7 Replies)
Hi all,
i'm trying to send an sms (notification sms) via a bash script executing throw crontab.
The script works fine, but the sms itsn't sent to me.
can you help me to resolve this issue, plz.
Thanks.
Yes - we probably COULD help you if you WOULD provide us with your script, the... (0 Replies)
Hello ,
I want to send mail via bash script but i want to add from parameter
for example i want to send to test@gmail.com and the sender will be test2@gmail.com
Thanks for all (1 Reply)
Hi,
My program A updates a log called logA.
I have a shell script S that is responsible to send emails reading from the log.
I want to trigger execution of the script whenever there is an update to the log.
Thanks in advance. (8 Replies)
Hi All,
How can I trap a character press in the shell script.
For eg:- I have a script runinng a infinite loops , I will need to dispay menu asking for run process of to stop process and process stauts like we do in glance
I have seen the traping the signal in glance command, (8 Replies)