Sponsored Content
Top Forums Shell Programming and Scripting Execute a command after a program was launched Post 302984032 by Xworks on Thursday 20th of October 2016 04:47:22 AM
Old 10-20-2016
Execute a command after a program was launched

Hi Experts,

I am creating a script to monitor a certain applications running in my Unix system.

My script order goes this way:

Code:
df -h /of/a/filesystem

tail -5 /path/to/an/application/availability

su -c "jsmon pf=(profile of my application) `echo "p"`" usradm

#EOF

I am encountering problem on my 3rd line. Basically what I wanted is when
my script run, it switches to user "usradm" execute command "jsmon pf=(profile of my application" and then echo the letter "p".

My script runs the switch to usradm command and executes program "jsmon pf=(profile of my application)" however won't execute "p" command after and getting error like:

Code:
 JStart Monitor Program
                                                                               jsmon=>appparam(2): fopenU("/home/usradm","r"): No such file or directory
jsmon=>No Profile used.
jsmon=>appparam: SYSTEMNAME neither in Profile nor in Commandline

 Thu Oct 20 06:45:30 2016 (initial: p)
  JsfOpenShm failed: object not found
  Cannot access shared memory.
 Thu Oct 20 06:45:30 2016>

Please help.

Thank you!



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 10-20-2016 at 05:58 AM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Urgent!! How to write a shell program to execute command to access internet?

hi, I am new ot unix. So, can i write a shell(c shell or korn shell) program to access internet? I mean if I run the program, it can access specified url and then copy the html to a file? Can anyone help me? And how can make the program runs every 1 hr? new comer (2 Replies)
Discussion started by: firebirdonfire
2 Replies

2. Programming

execve to execute a program

I tried using the following code to execute a program but it doesnt seems to be working .. I would like to know whats wrong wit it . execve("/bin/cat", "words", NULL); (0 Replies)
Discussion started by: winsonlee
0 Replies

3. Shell Programming and Scripting

how to execute this program?

Filesystem 1024-blocks Free %Used Iused %Iused Mounted on /dev/hd4 32768 16016 52% 2271 14% / /dev/hd2 4587520 1889420 59% 37791 4% /usr /dev/hd9var 65536 12032 82% 518 4% /var /dev/hd3 819200 637832 ... (1 Reply)
Discussion started by: sathyaac
1 Replies

4. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

5. Shell Programming and Scripting

Kill remote application launched via SSH command

Hi All I launch some application in a remote machine using ssh EXAMPLE ssh -X myname@mycompany@RemoteServerIp 'myApplicationName' When I want to kill the application I hit CTRL+C and I see a message 'Killed by signal 2'. Unfortunately on the remote machine the application is not really... (1 Reply)
Discussion started by: manustone
1 Replies

6. UNIX for Dummies Questions & Answers

how to execute program without using ./ or sh

Hi, I am a complete newbie for unix. I have just installed mysql on my MAC. I was wondering every time I wanted to use mysql I had to ./mysql or sh mysql everytime on /usr/local/bin/mysql/bin. How can I execute the mysql program without using ./ or sh. I chmod +x already. And what do I have to... (3 Replies)
Discussion started by: noppanit
3 Replies

7. UNIX for Advanced & Expert Users

Which script/shell/program launched a given script?

Dear gurus, I was wondering if anybody can help. Is it possible to distinguish whether a script was launched from a shell (interactively) or was called from another script? I basically need to do the following: if the script was run from the command line, I want to enable logging of the... (2 Replies)
Discussion started by: Snakeye
2 Replies

8. Shell Programming and Scripting

Execute a C program from Shell

Hi I want to create a shell script tha executes a C program and then retrieves information about it. I managed to run the program with: #!/bin/bash gcc -o program program.c ./program Now i want to get the id of the process (pid) Any help would be appreciated, Thank you (18 Replies)
Discussion started by: nteath
18 Replies

9. Ubuntu

I can't execute a C++ program, help!

My professor gave me a code with no errors. When I compile it's fine, it doesn't show any errors, but when I try to execute it shows this: line 3: syntax error near unexpected token '(' line 3: 'int main()' I searched through the Internet but I couldn't find any solution. Please!!!... (1 Reply)
Discussion started by: rosiiieee
1 Replies

10. UNIX for Advanced & Expert Users

Program Does not execute

Hi there, When I am trying to execute any shell script. The shell script only execute line 1 and I notice that the rest o the program was not executed. Please advise. # bash +x vmscript-4.sh Even when I enter this command there is not output. sudo su cd /tmp cp... (2 Replies)
Discussion started by: alvinoo
2 Replies
DBI::ProfileDumper(3)					User Contributed Perl Documentation				     DBI::ProfileDumper(3)

NAME
DBI::ProfileDumper - profile DBI usage and output data to a file SYNOPSIS
To profile an existing program using DBI::ProfileDumper, set the DBI_PROFILE environment variable and run your program as usual. For example, using bash: DBI_PROFILE=2/DBI::ProfileDumper program.pl Then analyze the generated file (dbi.prof) with dbiprof: dbiprof You can also activate DBI::ProfileDumper from within your code: use DBI; # profile with default path (2) and output file (dbi.prof) $dbh->{Profile} = "!Statement/DBI::ProfileDumper"; # same thing, spelled out $dbh->{Profile} = "!Statement/DBI::ProfileDumper/File:dbi.prof"; # another way to say it use DBI::ProfileDumper; $dbh->{Profile} = DBI::ProfileDumper->new( Path => [ '!Statement' ], File => 'dbi.prof' ); # using a custom path $dbh->{Profile} = DBI::ProfileDumper->new( Path => [ "foo", "bar" ], File => 'dbi.prof', ); DESCRIPTION
DBI::ProfileDumper is a subclass of DBI::Profile which dumps profile data to disk instead of printing a summary to your screen. You can then use dbiprof to analyze the data in a number of interesting ways, or you can roll your own analysis using DBI::ProfileData. NOTE: For Apache/mod_perl applications, use DBI::ProfileDumper::Apache. USAGE
One way to use this module is just to enable it in your $dbh: $dbh->{Profile} = "1/DBI::ProfileDumper"; This will write out profile data by statement into a file called dbi.prof. If you want to modify either of these properties, you can construct the DBI::ProfileDumper object yourself: use DBI::ProfileDumper; $dbh->{Profile} = DBI::ProfileDumper->new( Path => [ '!Statement' ], File => 'dbi.prof' ); The "Path" option takes the same values as in DBI::Profile. The "File" option gives the name of the file where results will be collected. If it already exists it will be overwritten. You can also activate this module by setting the DBI_PROFILE environment variable: $ENV{DBI_PROFILE} = "!Statement/DBI::ProfileDumper"; This will cause all DBI handles to share the same profiling object. METHODS
The following methods are available to be called using the profile object. You can get access to the profile object from the Profile key in any DBI handle: my $profile = $dbh->{Profile}; flush_to_disk $profile->flush_to_disk() Flushes all collected profile data to disk and empties the Data hash. Returns the filename written to. If no profile data has been collected then the file is not written and flush_to_disk() returns undef. The file is locked while it's being written. A process 'consuming' the files while they're being written to, should rename the file first, then lock it, then read it, then close and delete it. The "DeleteFiles" option to DBI::ProfileData does the right thing. This method may be called multiple times during a program run. empty $profile->empty() Clears the Data hash without writing to disk. filename $filename = $profile->filename(); Get or set the filename. The filename can be specified as a CODE reference, in which case the referenced code should return the filename to be used. The code will be called with the profile object as its first argument. DATA FORMAT
The data format written by DBI::ProfileDumper starts with a header containing the version number of the module used to generate it. Then a block of variable declarations describes the profile. After two newlines, the profile data forms the body of the file. For example: DBI::ProfileDumper 2.003762 Path = [ '!Statement', '!MethodName' ] Program = t/42profile_data.t + 1 SELECT name FROM users WHERE id = ? + 2 prepare = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 2 execute 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 2 fetchrow_hashref = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 1 UPDATE users SET name = ? WHERE id = ? + 2 prepare = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 + 2 execute = 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576 The lines beginning with "+" signs signify keys. The number after the "+" sign shows the nesting level of the key. Lines beginning with "=" are the actual profile data, in the same order as in DBI::Profile. Note that the same path may be present multiple times in the data file since "format()" may be called more than once. When read by DBI::ProfileData the data points will be merged to produce a single data set for each distinct path. The key strings are transformed in three ways. First, all backslashes are doubled. Then all newlines and carriage-returns are transformed into " " and " " respectively. Finally, any NULL bytes ("") are entirely removed. When DBI::ProfileData reads the file the first two transformations will be reversed, but NULL bytes will not be restored. AUTHOR
Sam Tregar <sam@tregar.com> COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. perl v5.18.2 2013-06-24 DBI::ProfileDumper(3)
All times are GMT -4. The time now is 10:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy