Shell Script on Top Command
Hi All,
i need to write a shell script on unix top command.
Requirement:
In top command grep the more than 25% CPU utilization f60webmx process and that f60webmx process time stamp is more than 3HR's and also needs to grep the load average information in top command.
Please help me some one.
Duplicate of
How to create shell script on solaris "TOP" command
This one is locked.
@ O.P.,
Do not EVER multipost.
That is poor forum etiquette and you chance having all the multiposts spontaneously disappear same as spam posts disappear.
Similar Messages
-
Run shell script using Host Command
How do I run Unix Shell Script using Host command?
Please help me......Are you running the shell script from the same box as the forms are deployed in? If not, then HOST call will try to execute on the machine where the forms are hosted(App server).
-
Shell scripting for sftp command
Guy's
you may wondering how i can ask these question in this forum,actually it's related to abap,we have create
unix script that will upload file from remote sftp server
and put it into AL11 transcation (take any location from
your point of view),but instead of using shell script
that is having ftp the want to go for sftp,for your undersatnding following thing's i am working with
<b>Tcode</b>:sm69,sm49
<b>function module</b>:SXPG_COMMAND_EXECUTE
script that need to have sftp instead of ftp
Connecting to ftp server to get the file on the current server
SOURCE_FILE_NAME=TSPAR_`date +%Y%m%d`.txt
TARGET_FILE_NAME=TSPAR_`date +%Y%m%d`.txt
cd /interf/torrance/TCW/FI
ftp -nv << EOF
open 10.252.8.73
user sanju sanju
cd /home/sanju
get $SOURCE_FILE_NAME
EOF
cp SOURCE_FILE_NAME TARGET_FILE_NAME
rm SOURCE_FILE_NAME
<b>note:</b>above script is working ,but we want' sftp not ftp
don't try above script as such,because value's are
changed for sake of securityTry to execute same command using your OS .
ksh + x ( is for debugging ) shell script and see where its failing . I also did the same thing in last project as i have written 5 different shell scripts , for backup , append file , sending file to FTP location and then create email ...
Hope thisll help you
Thanks -
Shell script ------same as command Urgent please
Hi all,
i am executing a command it give more than two lines of ouput eg: df -h
by using shell script how can i display the output as same as aboveIf you're wanting to display the command being run, we usually assign this to a variable PGM
PGM=`basename $0`
echo $PGM
Or if you just want to echo without assigning it:
basename $0 -
Command line parameters and Shell Script -- URGENT
Hi folks,
I am facing some problem in the Shell script and the command line parameter.
The scenario is -- I am picking a file from a directory, whose path is <b>/interfaces/xid/receive/filename.dat</b>
I have to encrypt filename.dat and move it to another folder, whose path is <b>/interfaces/xid/send</b>. So, the encrypted file will reside in the <b>send</b> directory.
Now, I don't want to hardcode the new path, where the encrypted file has to be moved. Please let me know how to achieve this. Please consider this as urgent.
Have a look at the command line in the "before message processing" -- <b>/interfaces/xid/receive/xi_decompress.sh /interfaces%F</b>
Have a look at the shell script for the same --
#!/bin/sh
Setup environment variables
COMMPRESS_DIR=/interfaces/software/commpress
export COMMPRESS_DIR
LOG_DIR=/interfaces/software/commpress/log/
export LOG_DIR
IN_FILE=$1
export IN_FILE
Find the directory where the unencrypted file is deposited
IN_FILE_DIR=`dirname $1`
export IN_FILE_DIR
Make sure the working directory is where the unencrypt.key is...
cd $COMMPRESS_DIR
encrypt the file
if [ `uname` = "HP-UX" ]
then
find $IN_FILE | $COMMPRESS_DIR/compx $IN_FILE_DIR logpath=$LOG_DIR
else
find $IN_FILE | $COMMPRESS_DIR/compx-sun $IN_FILE_DIR logpath=$LOG_DIR
fi
Get the result of the encryption
RET_CODE=$?
Check decryption result
If error (retuen code <> 0), create an error log file in the
same directory as the input file.
if [ $RET_CODE -ne 0 ]
then
PREFIX="Decryption"
DATE_TIME=$(date +%Y%m%d_%H%M%S%N)
SUFFIX="err"
FILENAME=$/$_$.$
echo "Decryption Error log" >$FILENAME
echo "DATE_TIME: $" >>$FILENAME
echo "DIRECTORY: $" >>$FILENAME
echo "FILE: $" >>$FILENAME
echo "ERROR CODE: $" >>$FILENAME
fi
exit $RET_CODE
What else I need to add in this piece of code? Urgent help !!
Thanks a lot in advance.
NeeteshHi Satish,
I was able to figure that out, that we need to hard code the path as the 2nd parameter.
But I guess there is a way out in Unix where we can handle this situation, where we are not willing to hard code.
Anyways, thanks a lot for your input .. -:)
Cheers,
Neetesh -
Hello All,
I would like to transfer a file from one system to another system.
so i haven written shell script with ftp command as follows.
ftp -i 10.14.12.1<< END
cd C:\Temp
put $datafile
ascii
quit
But i am getting error.
Please let me know the sysntax followed by me is correct or thar remote system is down,
Many thanks,
Kumar.The ftp(1) command is not well-suited for scripting. Instead us the curl(1) tool:
curl -T myfile ftp://ftp.some.where/down/in/this/dir/
for example.
$ man 1 curl
for more details. -
NoClassDefFoundError when using Runtime to call a shell script
I have a java program that uses the Runtime.exec method to call a shell script that then calls another java program (the shell script and 2nd java program are a 3rd party product I have to call).
When I run my program as root, it works fine. When I run it as a regular user, I get the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: 'argument'
In the error message above, "argument" is just an argument I had to pass to the shell script, which then calls the 2nd java program. It is this second java program that is throwing this exception it seems. This is all in Linux (RH AdvSrvr 2.5). If I call the shell script on the command line as the regular user, not from the java program, it works fine; but I NEED to call it from the java program... it's a long story.
I have check Environment variables, system properties under both users during the processes and I cannot find any major difference. I have checked file permissions and everything.
Does anybody have a clue what is going on here? Please help me, thank you!Okay, we found the problem. Our in-house MASTER OF ALL found it. The argument that the jvm was trying to load as a class needed to be in quotes according to documentation, but the shell escapes out the quotes when run on the command line, whereas in my java process it was not, therefore the jvm thought it needed to load it as a class.
Clear as mud? -
Running shell script through JSP
Hi
I have shell script on my linux server .I want to create a jsp which calls the shell script .Currently i am writing JSP as
string cmd ="sh <path tp shell script>";
Runtime rt =Runtime.getRuntime();
Process p=rt.exec(cmd);
InputStream is = p.getInputStream();
p.waitFor();
I think there is nothing wrong with the concept .The script contains commands which contact the remote server like server on amazon .For running the instance of remote server command is issued and the server will give back the instance id (which takes time of 5 sec ).Based on the instance id given by remote server ,the following commands in script are executed .Now i have a confusion ,is it that commands use remote server connection did not allow the commands to execute properly or there is something wrong in my JSP code ??????
In either cases how do i make my jsp code run???
Plz reply as soon as possibleHi
Scriptlet will work properly since i have used it in running the script containing local commands like ls , ps, echo and so on...
But for the commands of remote server it did not work.
#2 Understanding of point will be easier if you are familiar of cloud computing .There are some commands like to know the status of our account .They are like normal shell script executed on command prompt .The result is fetch from the cloud (amazon) which generally takes 3 to 5 sec of time .The script containing these commands are working fine but when script is called through jsp page the commands are not executed.
one more thing these command do not required ssh or any other type of login ,only net connection .
Hope it is clear this time
Regards -
Deploy application using ant script vs shell script
Hi,
I work with OAS 10.1.2 and I'm using shell script with dcmctl command to deploy EAR into OC4J but I know that ant script do the same things. I want to know if my choice is good or is it better to use ant script ?
RegardsThis is difficult to decide.
When you have just a few ear files you deploy once in a while a shell script might be sufficient. When developing more complex systems you should use ant as this is easier to maintain.
cu
Andreas -
How to create shell script on solaris "TOP" command
Hi All,
i need to write a shell script on unix top command.
Requirement:
In top command grep the more than 25% CPU utilization f60webmx process and that f60webmx process time stamp is more than 3HR's and also needs to grep the load average information in top command.
Please help me some one.i need to write a shell script on unix top command.You have our permission to begin to do that.
These forums are NOT for doing your work for you. They are here to provide assistance for YOUR work.
I suggest you go get paper and pencil and write down all the steps you think you need to take to accomplish that. Write it down as if you were going to do that manually at the command prompt. Then put it all into a text file and save it with a file name of your script.
When you have that "script", you can run it and examine whether it succeeds or whether it has errors. Work at it for a while and fix whatever errors might happen.
When you are really, really stuck at it, you can paste your script into a reply of this thread and maybe someone will respond with suggestions for improvement. -
Running Shell script from command line
Hi,
I am getting a Exception in thread "main" java.lang.NoClassDefFoundError: TestRuntime/java error when I run the following code on my linnux box...can anyone please help
import java.io.*;
public class TestRuntime {
public static void main(String args[]) {
Runtime runtime = Runtime.getRuntime(); //get runtime information
try {
Process Child = runtime.exec("/usr/bin/ksh"); // execute command
BufferedWriter outCommand = new BufferedWriter(new OutputStreamWriter(Child.getOutputStream()));
outCommand.write("/home/mypath/tesh.csh");
outCommand.flush();
try {
Child.waitFor(); // wait for command to complete
} catch (InterruptedException e) { // handle waitFor failure
System.out.println("ERROR: waitFor failure");
System.exit(10); // exit application with exit code 10
} catch (IOException e) { // handle exec failure
System.out.println("ERROR: exec failure" + e);
System.exit(11); // exit application with exit code 11
}If I'm reading your code correctly, you're starting a Korn shell session, then executing your C shell script as if you were at at the session window's prompt. If that is correct, you haven't caused your standard out (stdout) to hit ENTER yet. I'm not an expert, but I hope this works for you.
Your code:
Process Child = runtime.exec("/usr/bin/ksh"); // execute command
BufferedWriter outCommand = new BufferedWriter(new OutputStreamWriter(Child.getOutputStream()));
outCommand.write("/home/mypath/tesh.csh");
outCommand.flush();I think you need to enter one extra line before the flush():
Process Child = runtime.exec("/usr/bin/ksh"); // execute command
BufferedWriter outCommand = new BufferedWriter(new OutputStreamWriter(Child.getOutputStream()));
outCommand.write("/home/mypath/tesh.csh");
outCommand.newLine(); // hit ENTER
outCommand.flush();P.S. If you're running this script and your Java program from the same UNIX machine, you could just execute the shell script inside the runtime.exec() call. -
Using launchctl command within a shell script
I have successfully installed two daemons, and I would like to be able to disable and enable them via shell scripts, called by the daemons themselves. Here is my first shell script:
#!/bin/sh
# Testing for presence of a CODEBOY file
if [ -e "/Volumes/CODEBOY/Change.txt" ]
then
osascript '/Users/praxisii/Library/Scripts/MacScript.scpt'
launchctl unload -w '/Users/praxisii/Library/LaunchDaemons/WaitDaemon.plist'
launchctl load -w '/Users/praxisii/Library/LaunchDaemons/RunDaemon.plist'
fi
The daemon works just fine, running the background, calling this script, which is waiting for me to plug in my flash drive (entitled CODEBOY). When the flash is plugged in, the applescript is called, and the first launchctl command is executed, which disables the WaitDaemon. As advertised, the .plist file is re-written with the Disabled key set to true. The next line (which is supposed to enable the RunDaemon) is never executed.
Similarly, if the launchctl line is placed before the osascript line, the applescript is never called. It is as if the shell ignores everything after a single launchctl command, which it will execute.
Any ideas or comments?Gary:
Thank you for the link to the TN2083. Long, but very informative.
I appreciate all the other comments on this thread. I am an amateur AppleScript/UNIX scripter, and any opportunity to learn more is much appreciated.
I have completely re-worked my original launchd agent system for automatic processing of a file on a flash drive. Here is the .plist file that I now use:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>RunOSAscript</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>/usr/bin/osascript</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/casdvm/Desktop/AutoFlash.scpt</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>ServiceDescription</key>
<string>Runs Applescript directly</string>
<key>StandardOutPath</key>
<string>/Users/casdvm/Desktop/AutoFlashLog.txt</string>
<key>StartInterval</key>
<integer>25</integer>
</dict>
</plist>
The AutoFlash.scpt is an Applescript that simply uses the Finder to check for the presence of a specific file on the flash drive. If it is there, and a certain script property has a value of 2, then it runs the AppleScript that processes the desired file on the flash drive. Once that is done, the script property is set to 0 (to prevent the processing from happening over and over again.). Once the flash drive is removed, the script property is set back to 2 in anticipation of the next time the flash drive is plugged in.
It is much simpler than the two agents I was messing with beforehand. I did indeed discover that this .plist needs to be saved in the LaunchAgents folder of my user Library (thanks again for pointing that out, Gary).
The only problem that I have involves the continuous calling of the Applescript from the launchd agent. As you can see from my .plist file, that AppleScript is called every 25 seconds. I tried setting it up using the OnDemand key, but I kept receiving a re-spooling error of some sort (I don't recall exactly; my notes are sketchy on that phase of testing), so I just decided to have it go every 25 seconds. It really doesn't matter, since I can leave the flash drive plugged in all day anyway, and it only processes the desired file once.
Thanks again for all the commentary and discussion; I am grateful for the assistance.
Craig Smith -
Update command in Shell script
Hi friends
sqlplus -s / <<END
set feedback on;
update tran2 set sno=1;
exit;
END
when i am using update command in shell script like above
it is updating the database well...but i just want to know how many rows it is updating and i dont want to commit
for that
sqlplus -s / <<END
set feedback on;
update tran2 set sno=1;
set feedback off;
rollback;
exit;
END
It's working fine
is there any other method to do the sameWell what's exactly your requirement? The current requirement doesn't make a lot of sense.
How many row is going to be updated depends on where clause, if you have no where clause that essentially updating whole table, the number of row updated is count of your rows. -
Exit command in a Shell Script
I am trying to input an 'exit' command in a shell script. I am running Solaris 8. I have checked all of my documentation on the OS and cannot find the command syntax. Can someone help me? Thanks.
#!/usr/bin/env bash
# This a simple bash script outlining the procedures to get macports on OS X
# to auto update weekly via the ~/Library/LaunchAgents/net.ipatch.macportsUpdate.plist
# The first step is to update the port files
echo "Step 1: Update port tree"
port selfupdate
# The second step is to upgrade the outdated
echo "Step 2: Upgrade outdated"
port upgrade outdated
# The third step is to remove inactive ports
echo "Step 3: Remove inactive ports"
port uninstall inactive
# The fourth step is to clean the vile
echo "Step 4: Clean the vile"
port clean --all vile
Now invoke your script using sudo, as in:
sudo ./macportsUpdate.sh
This way you authentiate once, and from that point forward everything is run a 'root'
If you do not want to remember to prefix the script with sudo, then you could do the following:
#!/usr/bin/env bash
myPortUpdate()
# This a simple bash script outlining the procedures to get macports on OS X
# to auto update weekly via the ~/Library/LaunchAgents/net.ipatch.macportsUpdate.plist
# The first step is to update the port files
echo "Step 1: Update port tree"
port selfupdate
# The second step is to upgrade the outdated
echo "Step 2: Upgrade outdated"
port upgrade outdated
# The third step is to remove inactive ports
echo "Step 3: Remove inactive ports"
port uninstall inactive
# The fourth step is to clean the vile
echo "Step 4: Clean the vile"
port clean --all vile
# Now do all of the above with a single sudo command
sudo myPortUpdate
Now you can invoke the script and it will just prompt once for your admin password
macportsUpdate.sh
Message was edited by: BobHarris -
Output format of sqlplus commands under shell script
hi experts
Can you help with some problems please?
1.) I try to run shell script from dbms_scheduler, which runs sqlplus and the output of sqlplus commands is written to file using command spool. To this point everything is running ok.
My problem is, that output of this file is: (e.g.)
SQL> PROMPT ****************USERB******************
****************USERB******************
SQL> --SELECT sid
SQL> -- FROM v
SQL> -- WHERE audsid = SYS_CONTEXT('userenv','sessionid');
But I don't want the whole first line in the output file. I only want the output of this command, like on the second line.
2.) How Can I write two outputs from sqlplus using command spool running at the same time into one file?
Like in first issue described above. The main sqlplus create a job and this execute the background sqlplus using shell script. But both, the main and the background sqlplus are written to output file at the same time. But only one is written into. But I want the both outputs in the file.
How Can I do that, if I can?
Thanks a lot.user9357436 wrote:
hi experts
Can you help with some problems please?
1.) I try to run shell script from dbms_scheduler, which runs sqlplus and the output of sqlplus commands is written to file using command spool. To this point everything is running ok. then why are you here?
My problem is, that output of this file is: (e.g.)
SQL> PROMPT ****************USERB******************
****************USERB******************so remove PROMPT line from the file
>
SQL> --SELECT sid
SQL> -- FROM v
SQL> -- WHERE audsid = SYS_CONTEXT('userenv','sessionid');
But I don't want the whole first line in the output file. I only want the output of this command, like on the second line.
2.) How Can I write two outputs from sqlplus using command spool running at the same time into one file?you can not do so.
Like in first issue described above. The main sqlplus create a job and this execute the background sqlplus using shell script. But both, the main and the background sqlplus are written to output file at the same time. But only one is written into. But I want the both outputs in the file.
How Can I do that, if I can?Can't.
Now what?
>
Thanks a lot.Why using DBMS_SCHEDULER to invoke OS script to run sqlplus that runs SQL statements?
this is like making THREE Left Turns, instead of single Right Turn.
Just invoke PL/SQL procedure that does what needs to be done.
Maybe you are looking for
-
How can i get LatLng out of a database to work in maps?
Hello, I am struggeling with a problem with a project of mine for several months now. In Flash Builder i have a Flex Mobile Project with a list and on click, i want a map to show up. What i try to do is, get the coordinates from a database and transp
-
Filling aggregates is taking too much time
Hello, Filling aggregates is taking too much time for around 17000 records & we have checked the cube consistancy in rsrv is everything is fine . how can i trace the problem . THanks in advance. Ravinder
-
Cannot save PDF to Excel .xls
When I try to save my work file Microsoft sends an error report & I lose my work file.
-
Errors when entering responses manually
I have been encountering an error, when manually entering responses to an existing (and open) Form in Adobe FormCentral. We are currently collecting registrations for an annual event, and the majority of people register online (via the form). However
-
I have an I-Pad with retina display/Ipad 4. One year old and since update it has been rebooting itself regularly.