Applescript/Terminal: Get PIDs of processes starting with...
Hello,
Is there a way to return all the PIDs of processes starting with "Myapp_action_download" in a neat array in Applescript, so I can kill them using Terminal?
Something like this:
set openapps to {}
set openapps to (do shell script "the shell script which I don't know")
--This script gets all the PIDs of processes starting with "Myapp_action_download", and returns them in a neat array
set appcount to 0
repeat (count of items of openapps)
set appcount to appcount + 1
do shell script ("kill -9 " & (item appcount of openapps) as text)
end repeat
Kind regards,
Isaiah
try
tell application "System Events"
set procesList to the name of every process whose name contains "Myapp_action_download"
end tell
tell application "System Events"
set {procesList, pidList} to the {name, unix id} of (every process whose name contains "Myapp_action_download")
end tell
You'll have two lists one with the process name and one with the pid's. They will be in a one-to-one relationship. That is the first entry in the processList will correspond to the first entry in the pidList.
However if the apps aren't hung or in a weird state you should be able to just tell the process to quit without resorting to killing them.
Message was edited by: Frank Caggiano
Similar Messages
-
I can not upgrade the iOS on my phone, nor sync the phone because the process starts with backing up the phone which always hangs up at the backing up stage and then will not allow further progress.
And for this I guess that it is the backing up of my Podcasts - which are free downloads that causes the hang up. These are items that I have played and synced before without issues. I am thinking this way because these are Podcasts that I used to play but sundenly would not play on my iPhone. Each time I try to play anyone of them it generates the message - this movie could not be played.
I am scared of atempting a system restore because I guess I may lose my SMS for the past two months. Please approach the solution from this point of view.
Thanks
JoePlease refer to this thread.
https://discussions.apple.com/thread/3417041
It may have something to do with one of your backup files that has been corrupted before. -
Get name of process associated with PID
The subject is the question -- I have the PID(s). Either I'm overlooking something or this is far more difficult than I expected (would be happy to hear differently). Do shell script routine would be fine.
Yesterday I assigned some credits to the responses to my post, without comment. For anyone actually interested, I do have some comments.
In terms of the way I initially presented my question, Camelot's response was most on target. I said I had a PID and wanted to get the related process name, and he pointed me at "lsof PID" (with a length enhancement). Typically, that gave a result like "Default" whereas the full name is actually "Default Folder X" -- a result of calling for the first word (only) in the COMMAND column of the lsof result.
Niel's responses covered some ground that I had explored and given up on.
But in fact I had actually gotten PID's from "lsof /", so all this seemed pretty circular; it seemed silly not to figure out how to get a complete process name from lsof / in the first place. To that end, Nils C. Anderson of the UNIX forum pointed me to "lsof -Fc /" as a way of getting the complete COMMAND column of lsof /. The result includes a couple alpha identifiers and some PID info that can be edited out, and what's worked best for me is: set COMlist to do shell script "lsof -Fc / | sed -e 's/^p.*//' -e 's/c//'" -- a fast one liner.
There remains one issue (see below), but this approach has provided the best process name list yet, at least for open files.
The remaining issue is this: a small but significant number of open files return the COMMAND in the form (file name)\xxxxxxxx. If I want to compare that to a list of actual file names, somehow I've got to get rid of the "\xxxxxxxxx" portion of the COMMAND, but (maybe I'm blind) the escape seems to defy attempts at doing that. E.g., do shell script "echo " & (COMMAND)&" | sed 's/\xxxxxxxxx//' returns an error, and I haven't found a way to add the second escape AS is looking for. If I should do a new post on this specific issue, tell me that. -
How to get only vendor id start with number.
Can someone help me how I can only pull vendors that have their id start with number. thanks
SELECT DISTINCT v.refvendor_id, v.vendorname, v.vendorshortname,
v.obsolete_dt, v.corporationtype, v.incorporationstate,
v.website, v.irsnum, a.address_id, a.addresstype,
g.vncde2 ssn, g.vndt1 inactive, a.addressline1,
a.addressline2, a.city, a.state, a.zipcode, a.country,
a.telephonenum, a.faxnum, a.email, a.createdby
FROM refvendor v, refvendoraddress a, refvendor_gf g
WHERE v.refvendor_id = a.refvendor_id
AND v.refvendor_id = g.refvendor_id(+)
vendor Id
E1043
0123155
A1568
12654
desired out put
vendor id
0123155
12654Hi,
user13258760 wrote:
thank you for the reply. what if i want to pull vendors their vendor id is only number. for example
vendor id
1ABC12
123456
123C22
59865
I just want only to see
vendor id
59865TRANSLATE can remove all the numbers.
If there's anything left after you do, then it wasn't all numbers.
AND TRANSLATE ( NVL (vendor_id, '?')
, 'x0123456789'
, 'x'
) IS NULL -
Multiple process start with terminal?
How do I open multiple programs at one? I need it to open an executable, leave it running, open another executable. I'm not sure how to do this branch thing in the terminal
I want to use this for an .sh script
Last edited by caelestis (2009-04-29 22:52:18)If you want to run a program non-interactively, you can append "&" to the end of the line to send the process to the background, e.g.
somescript &
anotherscript & -
How to get Java3d applets to start with JNLPAppletLauncher on MacOS?
My Java3d applets start like they should with JNLPAppletLauncher on Windows, but they don't on MacOS. How can I get them to start like they should on MacOS? You can see my Java3d applets here:
http://astral.mobile-visuals.com/3d_visuals.php
I included the JAR's for MacOS in the applet code. Here is the code that I use:
<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
width=100%
height=98%
archive="astrals.jar,
http://download.java.net/media/applet-launcher/applet-launcher.jar,
http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dcore.jar,
http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dutils.jar,
http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
http://download.java.net/media/java3d/webstart/release/vecmath/latest/vecmath.jar">
<param name="codebase_lookup" value="false">
<param name="subapplet.classname" value="OrchideaOptM">
<param name="subapplet.displayname" value="Orchideic Morph">
<param name="jnlpNumExtensions" value="1">
<param name="jnlpExtension1" value="http://download.java.net/media/java3d/webstart/release/java3d-latest.jnlp">
<param name="progressbar" value="true">
<param name="noddraw.check" value="true">
</applet>I read the thread that you linked. Puybaret proposed a solution there, but I assumed that it didn't work? It seems like he suggested launching as applications, but I need to launch them as applets.
It seems like the problem is that Apple ships their JRE with Java 3D pre-installed, so the end-user must uninstall Java 3D in order for Java 3D applets to work on Mac. -
How can I get web searches to start with uk sites.
When I do a web search for a product it shows USA sites which is frustrating. How can I get UK sites to be the first sites displayed?
Cheers
PatHello lindyh, for specific Search results you can install specific Search Engine Plugins, example for google : http://mycroftproject.com/google-search-plugins.html
Google UK (SSL) en-GB (google.co.uk) by Mycroft Project
Google UK - the UK (SSL) en-GB (google.co.uk) by Mycroft Project
in general : http://mycroftproject.com/search-engines.html
for master password see the next links for details :
* [https://support.mozilla.org/en-US/kb/use-master-password-protect-stored-logins Use a Master Password to protect stored logins and passwords]
* http://kb.mozillazine.org/Master_password
thank you -
How can I unock my phone when the touch screen is broke/frozen? I have a replacement phone coming tomorrow and need to back-up to itunes. The phone is a 5.
All help is most appreciated.If the device has been regularly backed up and synced with iTunes, simply connect it to the computer and do a backup via iTunes.
If it has not been backed up regularly (or never backed up) there is no way to force a backup without a functioning screen. -
Search for all words in a table column that any of the words start with a certain letter
I have products table. Each row has a Description which may have a few words within it. I wanted to know if it's possible to search through it and find all descriptions that have match the search. But, I want it to consider it a match even if it's not the
first word of the description, but rather the start of any word in the description.
For example:
Descriptions
Nice Casual Gloves(This should show up, and although it's not in the very beginning of the description it's at the beginning of a new word.)
Nice Dressy Gloves(This should show up, and although it's not in the very beginning of the description it's at the beginning of a new word.)
Great Dresses (This should show up)
Fancy Outerwear
Glasses (This should show up)
Shoes
Sheer Stockings (This should not show up because although it has a "g" it's not in the beginning of a word.)
Boots
Galoshes (This should show up)
I would want to search within this list Where Description like 'G%' but I don't want it to only get the descriptions that start with "g" at the beginning of the description, but rather any "g" at the beginning of any word. I do not want
to get all descriptions that have a "g" somewhere in the word (then I could just do WHERE DESCRIPTION LIKE '%g%'), rather only if it somewhere within the description but at the beginning of any word.
Thank you so much
Debra has a questionThe most perfect solution would be to get a CLR routine to either (a) Do a regular expression match, (b) Run a split routine at CLR speeds then do a simple LIKE, or (c) both (a) and (b). If your requirements grow to handle more and more complex searches,
you may have to do it that way eventually.
However, like the other answers, here's a way to do it reasonably well given your current requirements. You may have to tweak the REPLACE logic if you have frequent OTHER forms of word delimiters.
Method: Pull data; add space before and after original text; replace all common word separators other than space with a space (so for example, "(These pretzels)", "He said 'These pretzels are making me thirsty" and so forth would
be replaced with a space before "The"; then do a Patindex (you could do with just a LIKE also) on the search string prefaced with a space. Here's an example, stealing from table sys.messages just for ease of demonstration.
With SampleData as
Select top 100 *
, ' ' + Replace(Replace(Replace(Replace(text, '"', ' '), '''', ' '), '/', ' '), '(', ' ') + ' ' as TextPlus
from sys.messages
where language_id = 1033
Select TextPlus
, patindex('% The%', textplus)
from SampleData
where patindex('% The%', textplus) > 1
Same logic, in the most concise format:
Select top 100 Text
from sys.messages
where language_id = 1033
and ' ' + Replace(Replace(Replace(Replace(text, '"', ' '), '''', ' '), '/', ' '), '(', ' ') + ' ' like '% the%' -
Javax.crypto.BadPaddingException: Data must start with zero
Actually, I didn't write the entire codes, most of it was written by someone here, and I only tried to add a method. Here:
public class RSAEncrypt {
private KeyPair keys;
private Cipher rsaCipher;
public RSAEncrypt() throws GeneralSecurityException {
KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
keygen.initialize(512);
keys = keygen.generateKeyPair();
rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
public byte[] encrypt(byte[] message) throws GeneralSecurityException {
rsaCipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
return rsaCipher.doFinal(message);
public byte[] decrypt(byte[] encryptedMessage) throws GeneralSecurityException {
rsaCipher.init(Cipher.DECRYPT_MODE, keys.getPrivate());
return rsaCipher.doFinal(encryptedMessage);
* @param args
public static void main(String[] args) throws Exception {
String message = "The quick brown fox ran away";
System.out.println("Message: " + message);
byte[] encrypted = new RSAEncrypt().encrypt(message.getBytes());
System.out.println("Cipher Text: " + HexBin.encode(encrypted));
byte[] decrypted = new RSAEncrypt().decrypt(encrypted);
System.out.println("Decrypted Text: " + decrypted);
}The idea is that the program should encrypt the String, "The quick brown fox ran away," which it does. But when it gets to this line:
byte[] decrypted = new RSAEncrypt().decrypt(encrypted);i get the error: javax.crypto.BadPaddingException: Data must start with zero.
But here's the funny thing: If I edit the codes so that the encryption and decryption are done in the constructor, it works! Here:
public class RSAEncrypt {
private KeyPair keys;
private Cipher rsaCipher;
public RSAEncrypt() throws GeneralSecurityException {
KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
keygen.initialize(512);
keys = keygen.generateKeyPair();
rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
rsaCipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
String message = "The quick brown fox ran away";
byte[] cipherText = rsaCipher.doFinal(message.getBytes());
System.out.println(new BASE64Encoder().encode(cipherText));
rsaCipher.init(Cipher.DECRYPT_MODE, keys.getPrivate());
byte[] decryptedText = rsaCipher.doFinal(cipherText);
String dText = new String(decryptedText);
System.out.println(dText);
* @param args
public static void main(String[] args) throws Exception {
new RSAEncrypt();
}So, I'm confused. The Data must start with zero error is coming up when I pass encrypted data to a method for decryption, but it doesn't come out when I run everything in one method or in the constructor. Why???
Also, when performing RSA encryption (or decryption) on a plaintext stored in a file (not a big file, just a file with probably one or two lines), this is what I do (and it works):
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
CipherInputStream cis = new CipherInputStream(new FileInputStream(new File("message.txt")),cipher);My question is, I do see some people doing this as well:
cipher.doFinal(byteArray);The fact that I don't have this in my code when encrypting data from a file, that's ok, right? I don't need to do a ".doFinal()" method, do I?
Edited by: glenak on Aug 19, 2010 4:26 AMglenak wrote:
I don't quite understand, but if you mean this:
String message = "The quick brown fox ran away";
System.out.println("Message: " + message);
RSAEncrypt rsaEncrypt = new RSAEncrypt();
Creates and instance of RSAEncrypt with a new random RSA key pair.
byte[] encrypted = rsaEncrypt.encrypt(message.getBytes());Encrypts with the random public key created in the first instance.
System.out.println("Cipher Text: " + HexBin.encode(encrypted));
RSAEncrypt rsaDecrypt = new RSAEncrypt();Creates and second instance of RSAEncrypt with a new random RSA key pair nothing to do with the first instance.
byte[] decrypted = rsaDecrypt.decrypt(encrypted);Attempts to decrypt the ciphertext created with the public key of the first instance using the private key of the second, and totally unrelated, instance.
System.out.println("Decrypted Text: " + decrypted);I still get the "Data must start with zero" error.
If you could show me an example of what you mean, it would help very muchNo example is required. You cannot encrypt with the public key of one key pair and expect to decrypt with the private key of a totally independent key pair. -
How to close Terminal Windows and terminate processes with Applescript?
I'm trying to quit the Terminal via AppleScript. I need to run 4 different Terminal scripts on a server but would also need to restart this server every day automatically... and my favorite choice would be to do this properly.
I suceeded terminating all other applications, cleaning folders and sending messages, but I did not find a solution quitting the Terminal!
When I tell it to quit, it asks if I want to terminate all processes, even if I use the "ignoring application responses" command. The Terminal gets stuck on that dialog box and one has to manually hit "Terminate".
Anyone knows about a solution how to avoid this prompt or how to default "Terminate"? There must be something like "close window 1 with process terminate", or?
Many thanks in advance!:-))) Sometimes the answer is so easy... Thanks a lot!
-
How do I fix a initializing problem with my macbook pro? I only get to the blank screen with the apple logo and the "processing something" sign... it just doesn't start the system....
Please help
MarceloIf there is no loading bar, it's usually a problem with a third party kext file in OS X itself.
You can press the power button down to force a hardware shutdown, then reboot holding the shift key down on a wired or built in keyboard, this will disable them and you go around and update your third party software.
Gray, Blue or White screen at boot, w/spinner/progress bar
Also take this time to backup your users files off the machine if possible.
Most commonly used backup methods
Sometime that won't work and you need to do more
..Step by Step to fix your Mac -
Where can I find "Getting Started with AppleScript"?
I googled it. And it doesn't show any links from Apple. I'm trying to learn AppleScript and the Language guide says to go through the Overview first which in turn recommends going through Getting Started with AppleScript.
I even searched Mac Reference Library but it just doesn't show up!
Any help?
NeeravNo, certainly not. I mean, I don't know any AppleScript, but I can say with certainty that the answer to that question is no.
Objective-C is a programming language that is an extension of the C language. It is the language that is used to develop applications for Mac and iPhone. Other languages like C++ and Java can be used as well, but Objective-C is the language that Apple really intends for you to use for Mac and iPhone development, since it is heavily integrated with the Cocoa framework (for Mac developemt) and Cocoa Touch framework (for iPhone development). You need to know the C language to learn the Objective-C language, and you need to know the Objective-C language to work with the Cocoa or Cocoa Touch frameworks, but AppleScript is a totally separate and different animal from these things. AppleScript is a scripting language, and although it can technically be used to create applications from what I understand, it is mainly used as a mechanism for controlling applications. For example, you could use AppleScript to tell a certain application to perform a certain task everyday at a certain time. You can use it to create automated workflows and whatnot. I think that's what it's mainly meant for.
It's worth noting, however, taht there is a development environment called AppleScriptObjC. I don't really know anything about this, except that it allows for AppleScript to be used as the primary programming language.
I found a lot of this information at [Wikipedia's AppleScript page|http://en.wikipedia.org/wiki/AppleScript], so you might want to consider looking over it real quick -- it might be helpful. Here is the link to [Wikipedia's Objective-C page|http://en.wikipedia.org/wiki/Objective-c] and [Wikipedia's Cocoa page|http://en.wikipedia.org/wiki/Cocoa_%28API%29]. As someone said on these forums, Wikipedia is far from the last word on any subject, but those links might be helpful for you for just getting an idea of what these things are all about.
Hope that helps some. Please let us know if you have any other questions. -
where do i go to get started with the disabled phone process. I selected the information regarding not syncing into itunes ever. but where do I go on the site to get started
You use iTunes and restore the phone from Recovery Mode. You will lose all content. http://support.apple.com/kb/HT1808
-
I am automating the process of sending appointment reminders to my clients. I started with an alert with an email in calendar using the clients email address as a custom entry in my me card in my contacts. this was resulting in three emails being sent with slightly different versions of the same address (see my previous post). Heating someone else's suggestion I created a workflow file to send an email and calling that file from an alert on my calendar. This is working and sends only one email to the client.
My calendar is on I cloud and I access it from three different computers so I can keep my appointment calendar current. The files that send the email only exist on one computer. My other computers show error messages when those emails get sent. It seems that each computer wants to send the email. It's a small problem but is there a way that I could not get those alerts.
But appreciate any thoughts about this. It seems like both problems might be related to the iCloud system.
Thank you in advance,
MichaelGood work, catch so far Michael, does seem to be a "feature" of iCloud syncing, not sure what you could do to disable it.
Maybe you are looking for
-
Confuse..p​ls help!!!
i have my App world before i upgrade my BB to v.5.... now its gone when i tried to download it,it says "Downloads via a USB connection are not enabled for this product. Please visit our mobile download site using the browser on your BlackBerry® smart
-
Changing The Spry Drop Downs Font For IE
How do you change the font so that the main menu item and the drop downs items both show the same font in Internet Explorer? The default for Internet Explorer sets them as two different fonts. I have tried adjusting every single MenuBarHorizontal C
-
Just downloaded an update on my macbook and now the screen is black
just downloaded an update on my macbook pro through the app store (March 20, 2015) and now I cant get into my computer. It will start and turn off but the screen is black. It flashes a white screen briefly and I can see a download bar but I cannot co
-
BO RAS SDK create DataFields dynamically
Environment u2013 unix, BO Enterprise server, DB2, RAS SDK We are trying to create a Crystal report from scratch using RAS SDK. The issue that we are facing is related to data binding i.e. creating connection, table and DB field objects dynamically.
-
[925 Series] msi 925xe neo platinum issue
dear guys i have just assembled my pc with the above-mentioned board but noted discrepancies with other 925-based boards when benchmarkings are performed. I understood that the same problem also occured with msi 915-based board but all seem to resolv