Can I run a shell script from the services menu?, part II

Remember this?
It is now possible.

Doesn't look like there is a direct way to do it.
The services are all Bundles, which is easy
enough to fake -- just copy one from /Library/Services
to ~/Services and modify the plist. Put your shell
script in Contents/MacOS/ and identify it in the
plist under CFBundleExecutable and hope for the
best
Where it gets sticky is CFBundlePackageType (APPL
for Application, FMWK for FrameWork, BNDL for
'loadable bundle', whatever that is] and NSServices.
CFBundlePackageType should pose no problem if Services
use the OS loader and handles file magic [and '#!' of
course].
NSServices specifies a named port that the app
listens on, the data type it receives, and so forth.
This looks a bit harder to fake. I'd bet Applescript
has the functionality, and there may be some
command-line hooks to backend that, or it may be
possible to netcat your way through it.
But it doesn't look trivial
Property List Key Reference
Anyways, tried it with a quick script that echoes to a
file, and haven't figured out how to refresh the
Services menu to get it to appear. Probably have
to NetInfo it or something ridiculous; doesn't appear
to watch the FS.
[ Edited by Apple Discussions Moderator; href URL ]

Similar Messages

  • Can I run a shell script from the Services menu?

    This would be kind of cool.
    Is there a simple way to do this?

    Doesn't look like there is a direct way to do it.
    The services are all Bundles, which is easy
    enough to fake -- just copy one from /Library/Services
    to ~/Services and modify the plist. Put your shell
    script in Contents/MacOS/ and identify it in the
    plist under CFBundleExecutable and hope for the
    best
    Where it gets sticky is CFBundlePackageType (APPL
    for Application, FMWK for FrameWork, BNDL for
    'loadable bundle', whatever that is] and NSServices.
    CFBundlePackageType should pose no problem if Services
    use the OS loader and handles file magic [and '#!' of
    course].
    NSServices specifies a named port that the app
    listens on, the data type it receives, and so forth.
    This looks a bit harder to fake. I'd bet Applescript
    has the functionality, and there may be some
    command-line hooks to backend that, or it may be
    possible to netcat your way through it.
    But it doesn't look trivial
    Property List Key Reference
    Anyways, tried it with a quick script that echoes to a
    file, and haven't figured out how to refresh the
    Services menu to get it to appear. Probably have
    to NetInfo it or something ridiculous; doesn't appear
    to watch the FS.
    [ Edited by Apple Discussions Moderator; href URL ]

  • How to run a shell script from the GUI?

    This is probably a dumb question...
    How do I run a shell script from the GUI? I've been told to double click it but when I do, it opens as a text file.

    The behavior you describe is that used by the KDE and GNOME desktops of Linux.
    Under OS X, if you make a script then mark it as executable, double-clicking on it in the Finder will not execute it. Actually, it uses a rather complex algorithm ([summarized here|http://arstechnica.com/reviews/2q00/macos-qna/macos-x-qa-2.html]) to determine what to do with it. This is implemented in Mac OS X' LaunchServices framework (incidentally, the associations are cached in /Library/Caches/com.apple.LaunchServices*.csstore and ~/Library/Caches/com.apple/LaunchServices*.csstore). You can read the details in the developer docs about LaunchServices.
    Anyway, in short, the suffix '.command' is a built-in type in the LaunchServices network that identifies a shell script. If you run
    /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServic es.framework/Support/lsregister -dump
    ... it will tell you as much.

  • How I run a shell script from the scheduler on 10.2.0.2.0 ?

    Hello Oracle People,
    I'd like to run a shell script from the Scheduler in my 10g database.
    Right now it is a simple shell script.
    Eventually it will wrap RMAN commands to back up my DB.
    I wrote a simple pl/sql script to create a job:
    -- cr_job10.sql
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'my_backup_job',
    job_type => 'EXECUTABLE',
    job_action => '/h/oracle/scripts/tst.sh',
    start_date => '06-SEP-07 5.33.00PM US/Pacific',
    repeat_interval => 'FREQ=DAILY',
    end_date => '08-SEP-07 4.00.00PM US/Pacific',
    enabled => TRUE,
    comments => 'My Backup Job');
    END;
    I see no errors when I run the above procedure.
    I checked DBA_SCHEDULER_JOBS and the job is in there.
    The scheduler, though, errors out with an error which I see in a trace file:
    /h/oracle/admin/orcl/bdump/orcl_j000_22396.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ORACLE_HOME = /h/oracle/product/10r2
    System name: SunOS
    Node name: sol
    Release: 5.10
    Version: Generic_118855-14
    Machine: i86pc
    Instance name: orcl
    Redo thread mounted by this instance: 1
    Oracle process number: 15
    Unix process pid: 22396, image: oracle@sol (J000)
    *** ACTION NAME:(MY_BACKUP_JOB) 2007-09-06 17:33:00.175
    *** MODULE NAME:(DBMS_SCHEDULER) 2007-09-06 17:33:00.175
    *** SERVICE NAME:(SYS$USERS) 2007-09-06 17:33:00.175
    *** CLIENT ID:() 2007-09-06 17:33:00.175
    *** SESSION ID:(140.13520) 2007-09-06 17:33:00.175
    *** 2007-09-06 17:33:00.175
    ORA-12012: error on auto execute of job 53267
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    I googled on this:
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    Google returned only 1 hit.
    There, I see some evidence that I need to configure something inside
    of Oracle to run shell scripts from the scheduler, but possibly just
    for machines running windows. I'm running Solaris.
    Do any of you know what I need to configure inside of Oracle to
    run shell scripts from the scheduler?
    -Owen

    Hello people,
    I should have added this bit of information:
    "The script runs fine from oracle's crontab."
    "The script runs fine from a shell owned by oracle."
    I'm getting responses telling me to check my env variables and permissions
    which would be helpful to a UNIX novice.
    I have a feeling that no one is using the scheduler to run RMAN scripts.
    Tim Hall suggested I take a close look at these files:
    $ORACLE_HOME/rdbms/admin/externaljob.ora
    $ORACLE_HOME/bin/extJob
    Currently I'm setup like this:
    bash sol root /h/oracle/product/10r2/bin 31 #
    bash sol root /h/oracle/product/10r2/bin 31 # ll $ORACLE_HOME/rdbms/admin/externaljob.ora
    -rw-r--r-- 1 root dba 52 Sep 7 15:29 /h/oracle/product/10r2/rdbms/admin/externaljob.ora
    bash sol root /h/oracle/product/10r2/bin 32 #
    bash sol root /h/oracle/product/10r2/bin 32 # cat $ORACLE_HOME/rdbms/admin/externaljob.ora
    # externaljob.ora
    run_user = rman
    run_group = rman
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 # ll $ORACLE_HOME/bin/ext*
    -rwsr-x--- 1 rman dba 30388 Sep 21 2006 /h/oracle/product/10r2/bin/extjob*
    -rwsr-x--- 1 rman dba 30392 Sep 21 2006 /h/oracle/product/10r2/bin/extjobo*
    -rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc*
    -rwxr-xr-x 1 oracle dba 300 Sep 21 2006 /h/oracle/product/10r2/bin/extusrupgrade*
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    On my system, the user 'nobody' has no shell so I cannot use nobody.
    I created a user named rman:
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 # su - rman
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    $
    $ id
    uid=220(rman) gid=220(rman)
    $
    $
    $ date
    Fri Sep 7 16:30:03 PDT 2007
    $
    $
    Jared points out that rman needs access to extproc:
    $ ls -la /h/oracle/product/10r2/bin/extproc
    -rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc
    $
    $
    Here is a demo of rman running his script:
    bash sol root /h/oracle/product/10r2/bin 35 # su - rman
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    $
    $
    $ ls
    scripts
    $
    $
    $ scripts/tst.sh
    $
    $
    $ cat scripts/tst.sh
    #! /bin/sh
    /usr/bin/date > /tmp/tst.sh.out.txt 2>&1 &
    exit 0
    $
    $
    $ cat /tmp/tst.sh.out.txt
    Fri Sep 7 16:31:23 PDT 2007
    $
    $ rm /tmp/tst.sh.out.txt
    $
    I am focused on this error:
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    And I am focused on this exit code: 274662
    What does 274662 mean?
    If the Scheduler gives me an error like "274662" rather than some English,
    it's obvious to me the Scheduler is a POS and I should not use it.
    And of course,
    If I cannot run RMAN from Oracle Scheduler, I'll use cron.
    -Owen

  • Can any one tell me how can i call a shell script from pl/sql

    i like to call shell script from pl/sql procedure.
    can any one suggest how can i do this

    Have you not mastered in asking the same kind of question ?
    First do write a script...
    no one will spoon feed you.
    How can i call a shell script from procedure
    How to call Shell Script from pl/sql block
    -Sk

  • How to run unix shell script from java web applet

    hi all
    i have created one java applet. my apache web server is on unix server.
    i have created one shell script in same directory where my .class and .htm files reside...
    how to run this shell script from applet? it should search this .sh file on server and not on the client browser machine...
    thanks in advance

    I suppose you could make the shell script into a CGI, configure the server to execute CGIs, and then make the applet open the URL of that CGI.

  • Can I remove items from the Services menu?

    I think the subject line says it all: can I remove items from the Services menu? I have a number of items in the Services menu that I never use and I would like to make the menu shorter to make it easier to access the items that I do use.

    There are a couple of things you could try. There's an application called Service Scrubber that is supposed to do this. But the web page says it's for 10.4, though it says it might work on 10.3
    Alternatively, you can edit the Info.plist or Info-macos.plist file in each application bundle to remove its service from the Services menu. This post at Mac OS X Hints has a pretty detailed description of how to do it. I tried this on my iMac running 10.3.9 and it worked just fine.
    Don't know about the Service Scrubber app, but if you edit the plist files, you'll need to log out and log back in before the changes take effect.
    Also, if you decide to edit the files by hand, I'd suggest just renaming NSServices by adding an "x" to the front or something, rather than deleting the item completely. That makes the changes easier to reverse.
    charlie

  • Run Unix command / Run Unix shell script from Forms9i

    Hi,
    I have a requirement to run Unix command and Unix shell scripts from Forms9i.
    I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
    Please point me towards any other way to achieve the same.
    I would really appreciate your help.
    Thanks,
    Kumar

    There is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
    The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands.

  • Run a shell script from FORM

    Hi,
    Is there a way that we can run a shell script on UNIX box from ORACLE FORMS 4.5 running on client PC (OS=windows on client,
    DB on unix).
    Thanks in advance for help

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Anton Weindl ([email protected]):
    You can either use rsh or rexec (both available on windows). You will have to edit the .rhosts in the home directory of the unix user the script will be run under:
    <Client-Hostname> <USER>
    <USER> must match the Windows-User exactly.
    You can then execute the Shell-Script with
    host('rsh <HOST> -l <USER> sh <SCRIPT>',NO_SCREEN)
    Hope that helps
    Anton Weindl
    <HR></BLOCKQUOTE>
    Thank You Anton Weindl,
    It seems like the thing I want to use instead of the dbms_pipe.
    I tried to use rsh and gives me the following message
    command: "rsh taurus -l nileshs test.sh"
    where taurus is hostname and
    guest is unix username
    I am logged on windows 2000 with this name.
    "taurus permission denied:"
    "rsh can't establish connection"
    Let me know if I am missing anything.
    Thanks.
    null

  • How can i call a shell script from procedure

    I have a shell script.now i am i a situation to call that shell script from one of my procedures and need to get a value from that script.
    can u suggest me that how can a call the shell script from pl/sql?

    Is the same question you asked here
    How to call Shell Script from pl/sql block
    -SK

  • Can we execute a Powershell script from the Javascript?

    Hi,
    I have a certain requirement to add a Custom ribbon button in document library and there was a powershell script to be run for the selected item in the library.
    I have struck with executing a Powershell script from the javascript function.
    Can anyone please suggest me if this was achievable
    Thanks, Swaroop Vuppala

    Hi Swaroop,
    To execute server side code in a custom ribbon button script, using application page is a common way to do this, besides, you can also use a page dialog, which is similar with application page but display as model dialog, another way is javascript
    _dopostback and delegate control, the following article contains detailed information about this, please refer to it for more information:
    Invoke server side code on SharePoint ribbon click:
    http://sharepointnadeem.blogspot.in/2012/07/invoke-server-side-code-on-sharepoint.html
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Can i call unix shell script from B2B callout.

    Hi,
    We had a requirement to invoke a unix shell script from B2B callout implemented class. Here is the code in implementation class:
    public void execute(CalloutContext context,List input,List output)
    throws CalloutDomainException, CalloutSystemException {
    try {
    CalloutMessage cmIn = (CalloutMessage)input.get(0);
    FileOutputStream fos = null;
    String inputFile = "/home/orasoad/digitalsign/input/test.txt";
    String outputFile = "/home/orasoad/digitalsign/output/test.txt.gpg";
    File outFile = new File(inputFile);
    String str =cmIn.getBodyAsString();
    fos = new FileOutputStream(outFile);
    Writer out = new OutputStreamWriter(fos);
    out.write(str);
    out.close();
    String shellFile = "/home/orasoad/digitalsign/dg.sh";
    String cmd[] = new String[] { shellFile, inputFile, outputFile };
    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec(cmd);
    int i = pr.waitFor();
    BufferedReader br = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    StringBuffer sb = new StringBuffer();
    String line;
    while ((line = br.readLine()) != null) {              
    sb.append(line);
    CalloutMessage cmOut = new CalloutMessage(sb.toString());
    output.add(cmOut);
    } catch (Exception e) {
    throw new CalloutDomainException(e);
    We were able to execute the unix shell script from standalone java class with same code. But some how it is not working as expected while invoking the B2B java callout.
    Is it possible to invoke unix shell script from B2B callout?
    Please give inputs.
    Regards,

    Though it's not a good idea to invoke shell scripts from java callout but technically it will work.
    But some how it is not working as expected while invoking the B2B java callout.What is not working as expected? Any error in the log (server-diagnostic.log or server.out)?
    Regards,
    Anuj

  • You can't access your own content from the top menu anymore?

    Apple made a monumental FAIL decision for me regarding the new Apple TV.
    They really want to force feed their iTunes store to us so badly that they have now stripped all of your own content from the main menu.
    No longer can you go to TV Shows and watch... well, YOUR TV shows. Apple buried all of your personal content a couple of menus deep. In fact, the entire Music category is Now gone! Unbelievable!
    And I can't use album covers for a screen saver anymore? That was a great feature! i guess they don't want music associated with a TV device. Very bad decision in my opinion.
    This unit is a step BACK, not forward.
    Am is missing something? is there a way to get this content back to the front so I can easily access my stuff?

    Frozo wrote:
    Apple made a monumental FAIL decision for me regarding the new Apple TV.
    agreed
    They really want to force feed their iTunes store to us so badly that they have now stripped all of your own content from the main menu.
    agreed. the appletv is now an itunes store device (with your own content as a side issue).
    No longer can you go to TV Shows and watch... well, YOUR TV shows. Apple buried all of your personal content a couple of menus deep. In fact, the entire Music category is Now gone! Unbelievable!
    agreed
    And I can't use album covers for a screen saver anymore? That was a great feature! i guess they don't want music associated with a TV device. Very bad decision in my opinion.
    agreed
    This unit is a step BACK, not forward.
    agreed
    Am is missing something? is there a way to get this content back to the front so I can easily access my stuff?
    you're not missing anything unfortunately.

  • Running Shell scripts from the desktop

    Hi,
    I'm from the UNIX world rather than the mac one so have written a number of shell scripts. Lets call them foo.sh and bar.bash for the sake of argument.
    These are sitting in a folder on my desktop
    I can happily open a terminal session and run the scripts - and they work as I expect them to.
    If I open a Finder window and double click on the icons for the scripts what happens is that it opens TextEdit.
    Theres two things I'd like to change
    A. I'd like to change the behaviour so that the scripts run when I double clike them rather than opening an editor (possibly in a terminal window )
    B. I'd like to be able to change the editor from TextEdit to one I'm more used to...(I've installed Vim/Gvim which I quite like).
    A. - Haven't managed to get anywhere trying to solve this....
    B. - So far my attempts have got as far as...
    1...
    right-click -> open with -> Other -> select vim.app
    tick Always open as
    click open
    The file then opens in a vim window.
    however if I now close the vim application and double clike the file icon then the file opens in TextEdit again
    2...
    Right Click -> Get Info -> Open with VIM -> add -> Change all
    message appears
    'Are you sure you want to change all your Vimm.app documents to open with the application "vim.app"
    This change will apply to all Vim.app documents with extension ".sh" '
    click continue
    In the Info pane the 'Open with' selection widget immediately changes to say 'Open with: TextEdit.app'
    So I'm a bit stumped, can you help!
    Regards
    Mark
    Mac Mini   Mac OS X (10.4.3)  

    Thanks to both people who answered.
    You both gave me useful workarounds to my problem.
    Renaming the scripts to be 'foo.command' was very hepful and useful to know. I tried this and it does indeed work. I may use this in the future.
    I also had a play around with applescript and the automator to achieve similar results.
    I agree that double clicking to run the file and also edit it is mutually exlcusive - I'm sort of trying to work out how I could make it do 'either/or' as I choose. In the Windows world i'd have the option of setting 'open' to run the script (assuming I'd got cygwin installed and had assiciated it) OR 'Edit with vim' if I wanted to edit the file (assuming vim was installed!).
    Unresolved issue is that I'm still unable to get VIM to be associated with a .sh file.
    The way I would envisage it working in Mac world would be to be able to right click on foo.sh -> Open with... and have a list to select from immediately there like..
    Text Edit
    Vim
    Terminal (default)
    and be able to somehow add and remove apps from the list and change which is the default.
    My issue is that I don't seem to know how to get other apps than TextEdit to appear in the list - I suspect I need a better understanding of how these file/application associations work and are configured.
    Regards
    Mark

  • Can you run a wired router from the base station?

    I have a Airport Extreme base station, I bought it about 6 months ago so it's not too old. My question is can you plug a wired switch, hub or router into it? I was told no at the apple store but I don't see why you could not. All I want to do is run a 8 port switch from the base station so I can connect my other wired comps to the net. Thanks!

    My question is can you plug a wired switch, hub or router into it?
    Yes, just connect it to the LAN port on the AirPort Extreme base station (AEBS).
    I was told no at the apple store...
    They gave you incorrect information.

Maybe you are looking for

  • MBAM bitlocker-protected removable drives recovery keys saved on sql database not active directory

    Hi Guys I need help in saving bitlocker protected removable drives on the sql database instead of active directory . I have tried to play around with the policy and I am not winning , currently my GPO : Choose how bitlocker-protected removable drives

  • Compressed VideoFormat for sending Desktop Images

    Hi All, In JMF 2.1.1 solutions, the ScreenGrabber captures the desktop images and uses RGBFormat. Which other VideoFormats can we use so that we can send the compressed data using RTP but still allow higher resolutions. JPEGFormat suports higher reso

  • Pages Converter (for older Mac files)

    Hi all. I have a fairly new iMac that I bought last July.  I have been using Macs for years.  When iWork downloaded with Maverics I deleted iWork 09 from my HD.  I now try to open Pages files and they say I need to re-open them with iWork 09 and save

  • Could not parse Channel

    Hi friends, i'm trying create small scenario file to file.i've compled design and configuration.In id i'm selecting the cache notification,it shows following error "XI_SEND|file_recieve:        Could not parse Channel 'file_recieve'(ObjectId: 18e3fc1

  • Text Preview fail and comand+z only 2 levels

    I´ve update Mavericks, with Creative cloud installed, and now InDesigns goes very slow sometines, Some box text (when i working on it) disappears and the undo function only make two steps... I´ve read somewhere that resetting presets some of this pro