How to embed applescript into a shell script for notification center

I have managed to cobble this together:
You can run it in your Terminal, it is harmless, and will output results that will show you a notification from notification center:
I have items on my pasteboard as the results of a script, I want to pbpaste them into the below command, but can't get the syntax right.  I am not objectionable to string concatenation and building or whatever it takes.
osascript -e 'display notification "The url(s) are on your clipboard from my.app" with title "my.app has finished" subtitle "Some Sub title"'
Ideally, I want to put `pbpaste` in the "Some title" section, but I get the literal string. I try creating a variable, and get that literal string.
I tried building the entire string up as one variable, which in the Terminal echo'd out and works, but in Notification Center, I get the actually literal variable.  It's mainly a bash script, so the context witch to AppleScript i being a pain in the rear.
Suggestions? Any master out there that this makes any sense to?

As it stands, and the way you have your notification structured, this is the output from the notification center. I did an echo "From the clipboard" | pbcopy before I ran the following script. It uses a Bash function, osascript HERE document, and shows how to pass variables to the function, and receive them in AppleScript. If you want substring text that is not the result of pbpaste, then you can either make the string inside the AppleScript, or pass the string in as a variable.
To get this output, I used the following Bash/Osascript combination:
#!/bin/bash
#osascript -e 'display notification "The url(s) are on your clipboard from
#my.app" with title "my.app has finished" subtitle "Some Sub title"'
function notification () {
  `osascript <<-AppleScript
        set txt1 to "The URL(s) are on your clipboard from "
        set txt2 to " has finished"
    set appName to "$1" as text
    set subStr to "$2" as text
    set noteStr to txt1 & appName
    set titleStr to appName & txt2
    tell application "System Events"
        display notification noteStr with title titleStr subtitle subStr
        delay 1 -- give notification time to fire
    end tell
    return quit
AppleScript`
appName="foo.app"
#echo $appName
subTitle="$(pbpaste)"
#echo $subTitle
notification "${appName}" "${subTitle}"
exit 0

Similar Messages

  • How to avoid password prompt in shell script for zip password protection

    Hi
    I am trying to set password protection to my oracle database export backup. Once the backup completed, it should compress with a password protection. Thats the plan. Initialy we were using the gzip for the compression. Then realized that there is no password protection for the gzip. Started using zip option. I tried using
    zip -P <password> filename
    But it was throwing below error.
    -bash-3.2$ zip -P expreports REPORTS_2013FEB14.dmp
    zip warning: missing end signature--probably not a zip file (did you
    zip warning: remember to use binary mode when you transferred it?)
    zip warning: (if you are trying to read a damaged archive try -F)
    zip error: Zip file structure invalid (REPORTS_2013FEB14.dmp)
    Not quite sure why.
    Then I used zip -e REPORTS_2013FEB14.dmp.zip REPORTS_2013FEB14.dmp
    But this prompting for the password. As I am trying to put the command in the script. It will be tough if it prompts for the password.
    I would like to know how to avoid the password prompting by saving somewhere or how the code should be written. Tried using expect feature of shell script. Below was the code I tried. It didnt work.
    [oracle@SF40V6636 test]$ cat repexp.sh
    zip -e REPORTS_imp.log.zip REPORTS_imp.log
    expect "Enter password:"
    send "imprep"
    expect "Verify password:"
    send "imprep"
    So please help in avoiding this password prompt or let me know how to change the code.
    Thanks
    SHIYAS M

    How about using gpg and adding a secret key to the requirement of a password? No one should be able to decrypt your file, not by knowing only the password.
    1. Generate a public and private key pair:
    $ gpg --gen-key
    When it shows "We need to generate a lot of random bytes…" open another terminal session and type "dd if=/dev/sda of=/dev/null" to create traffic. When the public and secret key created and signed you can Ctrl-C the dd command.
    To see what you have created:
    $ gpg --list-keys
    2. Encrypt and gzip your stuff:
    $ tar zcf stuff.tgz file_or_folder
    $ gpg recipient "Some Name" encrypt stuff.tgz
    $ rm -f stuff.tgz
    3. Decrypt and extract the archive:
    $ gpg batch yes --passphrase "password" -d stuff.tgz.gpg > stuff.tgz
    $ tar zxvf stuff.tgz
    Again, knowing the password alone will not let anybody decrypt your stuff.

  • How to execute sql-queries through shell scripting in linux?

    How to execute sql-queries through shell scripting in linux?

    http://www.oracle.com/technology/pub/articles/saternos_scripting.html
    Two simple examples:
    #!/usr/bin/env bash
    set_orafra () {
       orafra=`echo 'set heading off
       select name from v$recovery_file_dest;
       exit' | sqlplus -s / as sysdba`
    set_orafra
    echo $orafra
    #!/usr/bin/env bash
    export ORACLE_SID=instance_name
    export ORACLE_HOME=/path_to_oracle_home_directory
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export PATH=/$ORACLE_HOME/bin/$PATH
    $ORACLE_HOME/bin/sqlplus -s <<EOF
    connect scott/tiger@my_instance_name
    INSERT INTO table VALUES (sysdate);
    exit
    EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM

  • How to embed html into keynote

    I want to embed the youtube code for a vid into my keynote presentation so when I export to flash I can post the entire thing online, the presentation will work and I can watch the vid too. Any thoughts on how to embed html into a keynote page?
    Thanks,
    Jeremy

    The only way to get video out of Keynote that I know of, is the QuickTime export. Now, if you use another tool after that (to convert the QuickTime video) that might be able to work for you.

  • How to embed excel into a region on portal AS

    How to embed excel into a region on portal AS??
    Any suggestions will be appreciated...

    Hmm. topic is from 2005. But havent they gotten something better than iframes since 2005??? I find iframes not flexible enough to paste in portlets, made by, say mod_plsql into a article publisher tool.
    For example, I want to make an article using my companies article publication tool (Intranett publisher) saying..
    Blah blah blah
    If you look at the table below u see the current data updated every hour:
    <iframe call to portlet with data>
    This data is blah blah blah etc
    When I use iframe I have to set the size (I dont know how big table will be in the future), and get ugly borders with scrollbars if I dont set size right. Isnt it any better code out there yet? Hopefully as easy as embed pictures from the outside.

  • SQL-Scripts into a Shell script

    Hi!
    After creating the database on a Linux machine, we need to create our Schema in that database.This Schema has many objects(tables, views,
    procs, triggers etc.). So executing each individual script would not be sensible. Is it possible to pack all sql scripts into one shell script and run that one?
    Thanks for your feedback/examples/links!

    If it's one-off task, why not put all of them in a SQL file and run it from SQL* Plus rather than using shell to cause sql plus which will in turn have to call the script?
    If it's a recurring task and you insist that you want to do it from Unix shell, you can do something like this:
    Place all scripts in a single file and put it under $HOME for ex. (save it as run_all_scripts.sql)
    Then write a shell script something like this:
    #!/bin/ksh
    connect_schema=scott/tiger
    sqlplus -s $connect_schema <<EOF
    @$HOME/run_all_scripts.sql
    EOF
    Regards
    Venkat

  • Shell script for below pl/sql script dbms_file_transfer

    Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
    I have trasfer the files from asm into filesystem .
    it is working . but i have to put in the loop
    begin
    dbms_file_transfer.copy_file(
    source_directory_object => 'src',
    source_file_name => 'ncsn',
    destination_directory_object => 'dest',
    destination_file_name => 'ncsn');
    end;
    Edited by: user8680248 on 27/10/2009 20:55

    user8680248 wrote:
    Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
    I have trasfer the files from asm into filesystem .
    it is working . but i have to put in the loop
    begin
    dbms_file_transfer.copy_file(
    source_directory_object => 'src',
    source_file_name => 'ncsn',
    destination_directory_object => 'dest',
    destination_file_name => 'ncsn');
    end;What database version?
    What are you trying to do exactly?
    It's working but you have to put it in a loop. Fine, what's the problem you are having?
    begin
      loop
        exit when ... whatever the exit condition is ...
        dbms_file_transfer.copy_file(
          source_directory_object => 'src',
          source_file_name => 'ncsn',
          destination_directory_object => 'dest',
          destination_file_name => 'ncsn');
      end loop;
    end;

  • 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 security

    Try 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 this’ll help you
    Thanks

  • Shell script for export backup in oracle 11g

    Hi,
    Oracle version 11.2.0..
    O/S-AIX
    How to write shell script for export full backup in oracle 11g and also need to remove 2 days of old backup.
    Regards,
    Raju

    How to write shell script for export full backup in oracle 11g
    Do you mean that export is your backup strategy ? is your database running in noarchivelog mode ? if so, then why ? if not so, then why not RMAN ?
    need to remove 2 days of old backup.
    If that mean remove files older than 2 days, you can use something like this :
    $ find <absolute directory path> -mtime +2 -exec rm {} \;

  • Shell script for DB backup

    HI,
    i have written some java code Database backup but there are some problems with that so now i need to write shell script for db backup.
    what i was doing in java code i was running command like that
    /usr/local/bin/tar cvzf /export/home/monitor/FILE_20091005.tar.gz FILES/*20091005.*which compress the all *20091005* files (myisam table files)
    but after compression file doesn't extract
    so i have to write shell script for that ..... can any body guide me how can i write that kind of script and put it in cron job.
    thanks

    soundar wrote:
    Hi all,
    I have migrated database from 8i to 10gr2.For Backup in 8i, we used a RMAN shell script (scheduled uding cron tab) to backup the database to Tape.(VERITAS BACKUP).
    I am new to 10G.I checked out the options to backup the database using Oracle Enterprise manager DB console.
    http://www.oracle.com/technology/obe/10gr2_db_single/ha/rman/rman_otn.htm#t1d
    I am planning to take a test backup using the steps mentioned inthe above url.Could any one suggest whcih is the best option for database backup,eiether to use Oracle Enterprise manager DB console or thru RMAN shell script for backup..?
    Edited by: soundar on Mar 9, 2010 10:53 PMDear soudar
    I woudn't suggest you to work with EM if you want to be a professional DBA. Start learning RMAN and use CLI instead of GUI
    Those who live by the GUI, die by the GUI

  • Shell script for RMAN backup

    Hi,
    on 10G R2 in AIX 6.1
    I'm looking for Shell script for RMAN backup.
    Moreover , if we should connect like this :
    rman nocatalog target sys/password@myDB << EOF
    backup as compressed backupset format '$savdir/ctl_%d_%T_%s_%p' current controlfile;
    exit
    EOFHow to avoid writting password in shell script ?
    Thank you.

    user522961 wrote:
    Can you please tell me in case of having a catalog , how to connect to catalog without writting password in script ? I mean , how to write the following in a way without password :
    #!/usr/bin/ksh
    export ORACLE_SID=myDB
    ORACLE_ENV_ASK=NO
    . /usr/local/bin/oraenv
    export savedir=/backups/myDB
    rman target /  << EOF
    connect catalog rman/password@myrepository
    backup as compressed backupset
        format '$savdir/ctl_%d_%T_%s_%p'
        include current controlfile;
    exit
    EOF:p

  • Windows Shell script for Javadoc

    Hello
    How to write the Shell script for javadoc...in this case we were
    java 1.4
    please Respond me with one example...

    Depends on the OS and what you want it to do.
    Here are several Windows examples:
    http://java.sun.com/j2se/1.4/docs/tooldocs/windows/javadoc.html#examples
    -Doug Kramer
    Javadoc team

  • Need Help in creating Unix Shell Script for database

    Would be appreciable if some one can help in creating unix shell script for the Oracle DB 10,11g.
    Here is the condition which i want to implement.
    1. Create shell script to create the database with 10GB TB SPACE and 3 groups of redo log file(Each 300MB).
    2. Increase size of redolog file.
    3. Load sample schema.
    4. dump the schema.
    5. Create empty db (Script should check if db already exists and drop it in this case).
    6. Create backup using rman.
    7. restore backup which you have backed up.

    This isn't much of a "code-sharing" site but a "knowledge-sharing" site.  Code posted me may be from a questioner who has a problem / issue / error with his code.   But we don't generally see people writing entire scripts as responses to such questions as yours.  There may be other sites where you can get coding done "for free".
    What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
    But the expectation here is for you to write your own code.
    Hemant K Chitale

  • How to embed images in long text of PM Notifications/Orders

    Dear Sir,
    How to embed images in long text of PM Notifications/Orders? Kindly help.
    Thanks & Regards
    PM Team.

    Hi,
      Unfortunately, You will not be able to view the graphics within the Long text editor screen.Only Limited word functionality is available on these editors.
      You will have to store these pictures separately as an attachment, through generic object services and then view them through that.
    Regards
    Narasimhan

  • Shell script for archive log transfer

    hi
    I dont want to reinvent the wheel.
    I am looking for shell script for log shipping to provide standby db.
    What I want to do is, get the last applied archived log number from alert.log
    Copy the files from archive destination according to this value.
    Cheers

    If you don't want to re-invent the wheel you use Dataguard, no scripts.
    And your script should use the dictionary, instead of some bs method to read the alert.
    v$archived_log has all information!
    Also as far as I know, the documentation describes manual standby.
    So apparently you not only don't want to reinvent the wheel, but you want the script on a silver plate on your doorstep!
    Typical attitude of most DBAs here. Use OTN for a permanent vacation.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • Video out stopped working with 10.4.6 update

    Hi, i've just installed the 10.4.6 update and now i have no video out. i have a video connected to the adc to s vhs connector. now when i start up my monitor starts up as the second display, and i have to put my computer to sleep and then wake it up

  • Is it possible to create a domain with 2 Foundation 2012 servers ?

    Hello, I need to install Windows 2012 servers, acting as DHCP servers, each one managing half of the IP range. There will be less than 5 users registered in this domain. My question is : can I use 2 Foundation versions (each one being a DC) ? Thanks

  • Boot Camp - NTFS and issue and Windows based defragmenters.

    I am interested in having a BootCamp developer contact me regarding NTFS partitions and what happens when you defragment while booted into Windows. Specifically, what is happening is that when a boot time defrag is performed while booted into Windows

  • Cannot get a secure connection to iTunes store

    Even though I have an internet connection I can never connect to itunes store. Keep getting error message

  • Seem to be losing a lot of HDD Space - How to get it back?

    Seem to be recently losing at least 40GB of HDD Space when only 10GB should be gone? How to reset Mac to get it back to normal - recently had 130Gb now down to 91GB, cleared at least 30GB of hdd space also, seem to have done nothing!!! PLEASE HELP!!!