Running a shell script in a Cocoa-Applescript, from the Resources folder?
Hello!
I need to use a bash script, but the script must be IN the application. I placed them in the "Supporting files", but i am not able to find them using "do shell script"
Thanks!
If you stick the script in the Resources folder you can get it by
path to resource "Bash Script"
If you want to put it in the folder Supporting files you need to construct the path
(path to me as string) & "Contents:Resources:Supporting files:Bash Script"
(where Bash Script is the name of your script)
Don;t know if there is a shorter way for the second case.
Similar Messages
-
How do I run a shell script via AppleScript?
Seems obvious, "do shell script" but that doesn't work for me.
I have an Automator app which runs a shell script, I'd like to take that into an AppleScript. My AS doesn't run the shell script. Perhaps "do shell script' is expecting the script to be located elsewhere? The rest of my AS runs fine, but the shell script doesn't.
repeat with i from 1 to count of items in exportFolder
do shell script
"exiftool -overwrite_original -Photoshop:CopyrightFlag='True'"
done
end repeat
As I say this works within an Automator app, what changes do I need to make it work in AppleScript?
Thanks!Camelot wrote:
repeat with i from 1 to count of items in exportFolder
What is 'exportFolder'? Where is it defined?
Thanks, 'exportFolder' is defined earlier in the script. The purpose of the script - which is run from within Aperture - is to rename the selected images, export them (to the 'exportFolder'), reset the version name and, using ExifTool, add metadata which Aperture does not write to exported JPEGs.
I have a version of this which works in Automator but I couldn't see any clues there on setting the path to ExifTool.
Here's the full (modified) script. Currently it returns an error
Result:
error "No file specified" number 1
so I now need to understand if I can use 'exportFolder' (defined at the start) to tell Finder which folder to use.
-- Creating filenames by making Version Name from the IPTC Headline and Filename (with hypens where spaces exist). The Aperture Version Name is used to create the file's name on export. Once exported the Aperture Version Name is reset to its original.
tell application "System Events"
set exportFolder to (choose folder with prompt "Choose an export folder")
end tell
tell application "Aperture"
set theSel to (get selection)
if theSel is {} then
error "Please select an image or two!."
else
repeat with theImg in theSel
-- Creating a new Aperture Version Name which will become the exported file's filename.
tell theImg
set headline to (get value of IPTC tag "Headline" of theImg)
set AppleScript's text item delimiters to " "
set theTextItems to text items of headline
set AppleScript's text item delimiters to "-"
set headline to theTextItems as string
set AppleScript's text item delimiters to {""}
set objectName to (get value of IPTC tag "ObjectName" of theImg)
set newVersion to (headline & "-" & objectName) as string
set name of theImg to newVersion
end tell
end repeat
-- Exporting the files as JPEGs to chosen folder/Project Name using the Version Name as a filename
export theSel using export setting "JPEG - Original Size" to exportFolder
-- Resetting the Aperture Version Name back to filename using IPTC Title (which should be the file's filename without suffex).
repeat with theImg in theSel
tell theImg
set title to (get value of IPTC tag "ObjectName" of theImg)
set name of theImg to title
end tell
end repeat
end if
end tell
--Using ExifTool to set Photoshop Copyright Status etc
tell application "Finder" to set theFiles to files of exportFolder as alias list
repeat with eachFile in theFiles
do shell script "/usr/bin/exiftool -overwrite_original -Photoshop:CopyrightFlag='True' -Photoshop:URL='http://davidgordon.co.uk/'" & quoted form of POSIX path of eachFile
end repeat
display dialog "Done that!" with icon note buttons "OK" default button 1 giving up after 10 -
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?
-OwenHello 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 -
Do I run a shell script (bsh) via PL/SQL stored procedure?
Hello guys,
Do I run a shell script (bsh) via PL/SQL stored procedure?
For example:
procedure X is
(variables)
begin
-- Read file data
vFileHandle := utl_file.fopen('/mnt/novell/', 'file.txt','r');
exception
when 'INVALID READ FILE' then
(I've to try running script to mount a Novell partition.);
end;
I've to installed Oracle 9.0.1 on Suse Linux.
Please, any ideas or hints ...
Thx and regards.You might be able to us the HOST command, I think you'd have to run it via dbms_sql, check this page for more details, not sure if it'll be of help but its worth a try..
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.817/a82950/ch8.htm
Cheers
Rob -
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 advanceI 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.
-
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. -
Secure login to remote UNIX host and run a shell script
Hi I am new to JAVA. I want to login to remote UNIX host from my application secure login (SSH) and run a shell script reside that remote host. Can any one let me know the way how to do it. If possible provide the code example.
Runtime.exec with an ssh command (not really recommended).
Much better, an SSH API (JSch, which needs JZlib, from http://www.jcraft.com/ is a good one). -
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 -
Running Unix Shell scripts through Java
How to run Unix shell scripts through Java program ?
Use:
Process p = Runtime.getRuntime().exec("sh script.sh");Then you can use:
p.getOutputStream and read the output of your program. -
I hope someone knows Unix better me. I created a shell script to run some ap comp sci classes, and whenever I want to run the script, I'm forced to type:
"./runMBS", while I want to just type "runMBS". Any suggestions will be nice.
ThanksIf you only type the name of a command (or script) the Unix shell only looks for those commands in the directories specified in the $PATH variable. If you provide a full or partial path to the command then the shell will run the command at that location... that's why including "./" in front of your shell script works... it tells the shell to run the command in the current directory (ie "./").
You can either:
- move your shell script to one of the directories specified in your $PATH variable
or
- add the directory containing your shell script to your $PATH
To modify the $PATH so that it includes the directory your script resides in use something like this in your .bash_profile:
<pre>
PATH=$PATH:/path/to/scriptdir
export PATH
</pre>
Although it's possible to include "./" in your PATH, it's not advisable and can present security problems. Read this explanation for more information.
Steve -
Running a shell script through java
Hi all,
I have a simple question here.
How can I run a shell script through java and put the text output into a string.
I'd be very grateful if you could show me sample code...
Have a great day,
PeshoRuntime.exec()
There are plenty of examples. Read the following before continuing, however, as it will save alot of headaches:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
Problem with running Bash shell scripts
I am unable to run Bash shell scripts on the UNIX Terminal application.
This is the transcript from the Terminal application.
Zhi-Yang-Ongs-Computer:/Applications/MetaPost/metapost-1.102 zhiyangong$ ./test1.sh
dyld: Symbol not found: _BC
Referenced from: /usr/local/bin/bash
Expected in: /usr/lib/libSystem.B.dylib
Trace/BPT trap
Zhi-Yang-Ongs-Computer:/Applications/MetaPost/metapost-1.102 zhiyangong$
Is this a problem with the the default installation of the Bash shell? Can I install the Bash shell on my own? If so, how can I do that?
Also, how can I get the dynamic linker, dyld, to refer to the symbol "_BC"? What does this symbol "_BC" refer to?This was in your posted output:
/usr/local/bin/bash
You are NOT running the default bash, you are trying to run a private copy.
The default Mac OS X bash is located at
/bin/bash
Try the following:
/bin/bash ./test1.sh
Does that work?
What is the first line of your script? Is it:
#!/bin/bash
Or maybe
#!/usr/bin/env bash
/usr/bin/env would find the first bash in PATH . I find this most useful for finding perl on different systems, but sh, ksh, bash, zsh, csh, tcsh are all generally found in /bin so I do not bother using /usr/bin/env
And if you have
#!/usr/local/bin/bash
Then the person that wrote test1.sh choose to use something besides the default bash
Or maybe this script was transferred from some system where you needed to put your own copy of bash in /usr/local/bin because the vendor does not distribute bash
Then again, you have not showed us what is inside your script, so it is possible something in the script called something else which invoked the /usr/local/bin/bash
If that is the case, then you might try:
/bin/bash -x ./test1.sh
which should show you the commands executed before it died. -
Use java to run a shell script which called a crontab command at Unix
I was trying to write an automate function using Java, which needs to call a shell script containing a crontab commend. The shell works fine without that crontab commend, but once I add it, the program won't execute that crontab commend.
public void cron(){
try
Process proc = Runtime.getRuntime().exec("script1");
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = br.readLine()) != null)
System.out.println(line);
int returnValue = proc.waitFor();
br.close();
} catch (Exception e){} //
script1:
#!/bin/sh
crontab cronfile
Can someone help me out for this? Thank you.Try this....
Process p = Runtime.getRuntime().exec("sh");
java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.OutputStreamWriter(p.getOutputStream()));
bw.write("script1");
bw.flush();
bw.close(); -
I need a shell script to move latest archivelogs from one server to another server..
Hi,
I need a shell script to move latest archivelogs from one server to another server..
Thanks&Regards,
Velea816fb9-f9ea-45ac-906f-36a8315970d0 wrote:
Thanks it's really helpfull..
Now i have pasted a shell script which generates archivelog and shows latest archivelog time..
just check let me know the answer, that how i need to execute it..
# Force a logswitch to get the last archivelog to the standby host
ORACLE_SID=ORCL
ORAENV_ASK=NO
. oraenv >/dev/null 2>&1
SwitchLogfile()
# Do logswitch
RESULT=`echo "Alter system switch logfile;" | sqlplus -S / as sysdba | grep 'System altered'`
if [ "$RESULT" = "System altered." ]
then
export RETURN=1
else
export RETURN=0
fi
# Do we need to do something with this return value?
export RETURN
GetArchiveTime()
CURYEAR=`date +%Y`
echo "set heading off;" > temp.sql
echo "set termout off;" >> temp.sql
echo "select to_char(first_time,'YYYY-MM-DD HH24:MI:SS') from v\$archived_log where sequence#=(select sequence# - 1 from v\$log where status='CURRENT');" >> temp.sql
sqlplus -S / as sysdba <
spool tempres.txt
@temp.sql
quit
EOF
cat tempres.txt | grep ${CURYEAR} | grep -v grep | awk '{print $1" "$2}'
#rm -f temp.sql tempres.sql
SwitchLogfile
GetArchiveTime
You seem to have ignored Dude's VERY good advice and continue to press down this ill-advised path. If you continue this approach, you WILL have problems at the very time you do not need any additional problems. Trying to recover your production database at 2:00 in the morning is not the time to be getting errors from rman because it can't find what it needs - because you decided to move them around yourself.
Please reconsider. -
How can I edit an AppleScript from the terminal?
I'd like to edit an AppleScript from the terminal. Does Mac OS X have built in support for this or do I need to get a 3rd party editor?
Have you tried using vim (a.k.a. vi)?
vi /Library/Scripts/iChat/Auto\ Decline.applescript
At least in this case, it's just a textfile. The 'file' command shows it to be:
file /Library/Scripts/iChat/Auto\ Decline.applescript
/Library/Scripts/iChat/Auto Decline.applescript: Mathematica, or Pascal, Modula-2 or 3 code text
Hope this helps.
Andy
Maybe you are looking for
-
Can a SQL Server dump be loaded into oracle?
Hi All, I'm wondering, if we have a sql server DB dump, is there anyway to load the data into Oracle? (other than loading the dump into a sql server and then using OMWB? ) Thanks in advance, Sudheer
-
Can anyone help me? I have a new computer with windows 7 (64bit). My Palm device is a Tungsten T5 I tried first to install Palm Desktop from the CD (to be able to switch to outlook sync). But this version will not install. Then I installed Palm Deskt
-
Is Operation Undo/Reversal possible in SAP ME?
Hello Experts! I have reported/completed an operation for an SFC in a POD and its status changed to In-Queue for next operation. I was wondering if there is any way to undo the reporting on the previous operation so that we can redo it at a later tim
-
Printer setup on Solaris 8 x86
I have a Solaris 8 x86 box and try to attach a Brother HL-760 printer to LPT1. The printer is HP5 compatible, supports PCL5, but no Postscript. I tried to attach it with HP printer driver, it was a successful experience. However, I can only print tex
-
Resource management - headcounts
Hi Experts, Has any of you have some experience on managing the role demand in terms of headcount (instead of week, days, hours)? Could you please share the approach to these solutions? Thanks in advance. Best regards, Neil