Visit The New, Modern Unix Linux Community

Doing a capture while another command is executing?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Doing a capture while another command is executing?
# 1  
Doing a capture while another command is executing?

Basically what i'm trying to do is execute an update command and at the same time have the system do a TCPdump to file for that update traffic.

So I would like to connect the two commands so that the tcpdump terminates automatically when the update finishes/fails/whatever.

Right now I have it to the point where it will ask me which interface to capture on and then it will execute the update and start doing a capture.

echo; netstat -i | awk '{print $1}' ; echo ; echo 'Interface to capture on?' ; read capture ; update & tcpdump -n -i $capture -w /tmp/capture.cap host

---------- Post updated at 01:24 PM ---------- Previous update was at 12:49 PM ----------

I have made a little progress on this.. Is there any way I can execute a command in the background and then save that new process ID to a variable?

So I could execute a command, save the process ID ex 1000 to variable Y.

Then when i'm done with all my commands I could just issue kill $Y to end the process still running?

So I basically just revered it. I run the capture in the background. Execute the update then kill the capture process.

---------- Post updated at 01:55 PM ---------- Previous update was at 01:24 PM ----------

Ok so looks like $! returns the process ID of the command that I just executed in the background.

So I got it to work by having it start the capture, then execute the update, then when the update is finished I did kill $! and that takes care of it.

I swear half the time I post something online I wind up figuring out my own answer before too long.

Last edited by Yogesh Sawant; 04-21-2010 at 03:54 AM.. Reason: added code tags

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #578
Difficulty: Medium
Lists are ordered collections that are essentially static arrays.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture output of command triggered in background

Is there any way to trigger a sequence of commands in parallel and capture their output in variables? e.g. something on the following lines x=`echo "X" &` y=`echo "Y" &` z=`echo "Z" &` so that $x, $y, and $z evaluate to X, Y and Z res. (7 Replies)
Discussion started by: jawsnnn
7 Replies

2. Solaris

How to capture Output of truus command

Hi I want to check if some process is sleeping. I can see that in truss -p <pid> I want to capture output and check that output if proces sis sleeping. Please suggest way to capture output of truss command or other way to check if process is sleeping (1 Reply)
Discussion started by: ankush_mehra
1 Replies

3. UNIX and Linux Applications

How to capture the value returned by a stored proc while executing it from SQSH connection

I have a very simple set up I am connecting to a MS SQL db using SQSH statement from a shell script In this sqsh connection i am trying to execute a stored proc However I want to capture the value returned by the stored proc. I haven't really come across anything useful so far which would... (0 Replies)
Discussion started by: shishirkotkar
0 Replies

4. Shell Programming and Scripting

Capture IP and command type in linux script

hi guys, is there any way to capture the ip address of users who log-in to linux then capture the command executed together with the time and date? example output : ls -ltr Aug 6 16:38:40thanks in advance. (2 Replies)
Discussion started by: d3xt3r
2 Replies

5. Linux

How do I capture responses from the chat command?

Unfortunately googling the word 'chat' gives you zebedee billion responses that relate to everything and few of them refer to the linux chat command. I've read the man page and found a couple of examples but can't see how to do this. I want to query the modem for it's manufacturer, product id... (8 Replies)
Discussion started by: Bashingaway
8 Replies

6. Shell Programming and Scripting

Enter the command to capture output--help

&& echo "PLEASE enter the command to capture output" || echo "Processing your command manual" x=$# echo $x while do while man $@ | read -r line do >$@.txt ... (1 Reply)
Discussion started by: rrd1986
1 Replies

7. Solaris

How to capture only some part of output when command executed??

Hi, When I execute this command prtdiag -v output sample : System clock frequency: 160 MHZ Memory size: 4GB ==================================== CPUs ==================================== E$ CPU CPU CPU Freq Size ... (4 Replies)
Discussion started by: vijaysachin
4 Replies

8. Cybersecurity

What command or script to capture a system snapshot?

Some background on what I am trying to accomplish - Accreditation/Certification for DoD (Unix/Linux) system: I am trying to improve the process for capturing key system information in preparation for performing a formal security review of a Unix or Linux system. This is in addition to the SRR... (1 Reply)
Discussion started by: SecureMe
1 Replies

9. Shell Programming and Scripting

Capture entire line in ps command

I need to determine what processes are running at certain times of the day. I have a script that issues the /usr/ucb/ps aux command and captures it to a file. I want to see the cpu usage and memory usage. This command lops off the end of the of the display line so I can't see the entire... (2 Replies)
Discussion started by: MizzGail
2 Replies

10. Shell Programming and Scripting

Capture the command run in the log file

Hi , I have seen some log files where they have captured the command that is being executed, comments present in the scripts and the out put of the command as well, through scripts. could any one of you please let me know how do i do that? Thanks in advance. Cheers, Waseem (4 Replies)
Discussion started by: ahmedwaseem2000
4 Replies

Featured Tech Videos