Bash shell scripting
Dear Mac Users:
I have a bash script which I copied from a bash book to learn how to use bash. Whenever I try to run it on Linux (cygwin--Windows Linux interpreter) it throws an error that something is wrong with the syntax.
But when I try to run the same script on my Mac using Terminal.app the bash shell throws an error saying access denied. I chowned a copy of bash and referenced this copy in my script but I still get the error. I also chowned the script to the user account on my Mac. Why can I not run the script?
#!/bin/bash
# cookbook filename: mkalbum
# makalbum - make an html "album" of a pile of photo files
# ver 2.0
# An album is a directory of html pages.
# It will be created in the current directory
# An album page is the html to display one photo,with
# a title that is the filename of the photo, along with
# hyperlinks to the first, previous, next, and last photos.
# ERROUT
ERROUT()
printf "%b" "$@"
} >&2
# USAGE
USAGE()
ERROUT "usage: %s <newdir>
" $(basename $0)
# EMIT(thisph, startph, prevph, nextph, lastph)
EMIT()
THISPH="../$1"
STRTPH="${2%.*}.html"
PREVPH="${3%.*}.html"
NEXTPH="${4%.*}.html"
LASTPH="${5%.*}.html"
if [ -z "$3" ]
then
PREVLINE='<TD> Prev </TD>'
else
PREVLINE='<TD> Prev </TD>'
fi
if [ -z "$4" ]
then
NEXTLINE='<TD> Next </TD>'
else
PREVLINE='<TD> Next </TD>'
fi
cat <<EOF
<HTML>
<HEAD><TITLE>$THISPH</TITLE></HEAD>
<BODY>
$THISPH
<TABLE WIDTH = "25%">
<TR>
<TD> First </TD>
$PREVLINE
$NEXTLINE
<TD> Last </TD>
</TR>
</TABLE>
</BODY>
</HTML>
EOF
if (($# !=1 ))
then
USAGE
exit -1
fi
ALBUM="$1"
if [ -d "${ALBUM}"]
then
ERROUT "Directory [%s] already exists.
" ${ALBUM}
USAGE
exit -2
else
mkdir "$ALBUM"
fi
cd "$ALBUM"
PREV=""
FIRST=""
LAST="last"
while read PHOTO
do
# prime the pump
if [ -z "${CURRENT}" ]
then
CURRENT="$PHOTO"
FIRST="$PHOTO"
continue
fi
PHILE=$(basename "${CURRENT}")
EMIT "$CURRENT" "$FIRST" "$PREV" "$PHOTO" "$LAST" > "${PHILE%.*}.html"
#set up for next iteration
PREV="$CURRENT"
CURRENT="$PHOTO"
done
PHILE=$(basename ${CURRENT})
EMIT "$CURRENT" "$FIRST" "$PREV" "" "$LAST" > "${PHILE%.*}.html"
# make the symlink for "last"
ln -s "${PHILE%.*}.html" ./last.html
# make a link for index.html
ln -s "${FIRST%.*}.html" ./index.html
Similar Messages
-
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. -
Invoking a bash shell script from Java code
Hi All
I am trying to invoke a Bash shell script using java code. The arguments required are "source wmGenPatch <source dir> <destination dir> no_reverse.
in the code I have specified the arguments considering the cannonical paths of the files as the code may run on Unix or windows platform.
I am getting a error while invoking Runtime.getRuntime().exec(args). The error is as follows :
"The Error Occurred is: CreateProcess: source D:\Package4.0\workspace\DiffEngineScripts\v4a02\wmGenPatch D:\Package4.0\workspace\fromImageFilesDir\ D:\Package4.0\workspace\toImageFilesDir\ no_reverse error=2"
It seems that error=2 indicates that the 'file not found' exception. But i can see the directories referred to in the error at place in the workspace.
Kindly advice.
Thanks in advance.Hi All
I am pretty new to invoking bash shell scripts from java and not sure if i am progressing in right direction.
The piece of code tried by me is as follows
try {
currentDir = f.getCanonicalPath();
} catch (IOException e) {
if (currentDir.contains("/")) {
separator = "/";
} else {
separator = "\\";
String args[] = new String[7];
args[0] = "/bin/sh";
args[1] = "-c";
args[2] = "source";
args[3] = currentDir + separator + "DiffEngineScripts" + separator
+ "v4a02" + separator + "wmGenPatch";
args[4] = sourceFileAdd;
args[5] = destFileAdd;
if (isReverseDeltaRequired) {
args[6] = "reverse";
} else {
args[6] = "no_reverse";
try {
Process xyz = Runtime.getRuntime().exec(args);
InputStream result = xyz.getInputStream();
InputStreamReader isr = new InputStreamReader(result);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
System.out.println(line);
int exitVal = xyz.waitFor();
System.out.println("Leaving Testrun.java");
} catch (Throwable t) {
t.printStackTrace();
and on running the same i am getting Java.io.IOException with the stack trace
java.io.IOException: CreateProcess: \bin\sh -c source D:\Package4.0\workspace\DiffEngineScripts\v4a02\wmGenPatch D:\Package4.0\workspace\fromImageFilesDir\ D:\Package4.0\workspace\toImageFilesDir\ no_reverse error=3
kindly advice
Thanks in advance -
Bash shell script to exception when database has been shutdown
Hi, I'm quite new in shell scripting. I created the below simple script to do a check on the database, it's a count so it works fine... if the database is there. Now I want to be able to catch if the database is or is not there, what I tried so far didn't work, can anybody please give me a hand with this?
The shell script file "start_check.sh":
#!/bin/bash
# Set environmental variables
. /home/oracle/env/usrdwh1.env
TEMP_FILE=rwcnt
runCheckQuery()
# Run query and dump result into the TEMP_FILE
sqlplus -s "/as sysdba" > /tmp/${TEMP_FILE} << EOF
@/u02/reports/sql/start_check.sql
EOF
if [ $? -eq 0 ]
then err_num=0
else err_num=1
fi
################ MAIN ####################
runCheckQuery
row_count=`cat /tmp/${TEMP_FILE}`
if [ $err_num -eq 0 ]
then
# If no rows were found then send an email alert
if [ $row_count -eq 0 ]; then
echo 'No process found - Please investigate' | mailx -s "Daily check ALERT" [email protected]
fi
else
# There was an error when trying to connect to the db. Need to report it
echo 'Database connection error - Please investigate - Error Message: (' $row_count ')' | mailx -s "Daily check ALERT (Database connection error)" [email protected]
fi
# Remove the tmp file
rm /tmp/${TEMP_FILE}
The sql script file "start_check.sql":
SET SERVEROUTPUT ON
SET FEEDBACK OFF
WHENEVER SQLERROR EXIT;
DECLARE
row_count NUMBER;
BEGIN
SELECT COUNT(*)
INTO row_count
FROM dw_ml_ba ml_ba
WHERE sys_id = 'CCX'
AND ml_ex_start_datetime > TRUNC(sysdate);
DBMS_OUTPUT.PUT_LINE(row_count);
END;
EXIT
Edited by: leocoppens on Jan 4, 2013 4:05 PMThere may be a better, but here is a shell script that works:
#!/bin/ksh
# db_check.sh
# Script used to check if one or all of the databases on
# one server are available.
# Parameter Description
sid=$1 # Database SID or Keyword 'all'
function check1db
sid=$1 # Database SID
ORAENV_ASK=NO
. /usr/local/bin/oraenv "$sid"
ORAENV_ASK=YES
if [ $(ps -ef|grep "ora_smon_$sid"|grep -v grep|wc -l) -eq 0 ]
then
echo "%-Error, Database $sid is NOT available - Not started\n" >>${CHKLOG}
return 1
fi
dbok=$(\
sqlplus -s / <<!
if [[ $(echo $dbok|cut -d' ' -f1 ) == 'ERROR:' ]]
then
echo "%-Error, Database $sid is NOT available - Started with errors\n" >>${CHKLOG}
return 1
else
echo "%-Info, Database $sid is available\n" >>${CHKLOG}
fi
return 0
} # end function check1db
# Set some environment variables:
ORACFG=/etc # Location of oratab
ORALOG=$HOME/logs # Location for result log
EMAIL='[email protected]' # E-mail to send alert
sid=${sid:-'all'}
echo "$0 Job started at: `date` "
BDATE=$(date +%y%m%d)
export CHKLOG=$ORALOG/db_check_${sid}_${BDATE}.log
echo "$0 on `date`" >$CHKLOG
if [ "$sid" = "all" ]
then
i=0
stat=0
cat $ORACFG/oratab | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
sid=`echo $LINE | awk -F: '{print $1}'`
check1db "$sid"
stat1=$?
((stat += $stat1)) # Combine the Status of All Calls
((i = $i + 1)) # Count Number of Databases Checked
esac
done
((j = $i - $stat)) # Count Number of Databases Available
echo "\n%-Info, `date +%c`,\n\tTotal databases checked = $i,\n\tAvailable = $j, Not available = $stat\n" >>${CHKLOG}
else
check1db $sid
stat=$?
fi
# Beep operator if database down.
if [ ${stat} -ne 0 ]
then
SUBJ="Database(s) alert."
mailx -s"$SUBJ" $EMAIL <$CHKLOG
fi
echo "$0 Job stoped at: `date` "
exit $stat:p -
Port AppleScript to bash shell script
Hi all,
I made this script with the help of Neil from these forums. The purpose of the scrip is so that my friend can set up a share point on his NAS which is simply full of links so that if people access the NAS (its full of music and movies) if the delete a link, the file stays where it is.
The issue he has now, is that when he make the links in MacOS, a Windows system will no follow them. Is there a way around this or should the script be ported to a bash script so that the links can be created internally on his BSD NAS.
Thanks for any help and suggestions.
set these_items to (choose file with prompt "Choose files to link:" with multiple selections allowed)
set link_folder to (choose folder with prompt "Choose folder to place links in:")
repeat with this_item in these_items
tell application "Finder" to reveal this_item
set this_path to the quoted form of the POSIX path of this_item
set shell_folder to the quoted form of the POSIX path of link_folder
do shell script "ln -s" & space & this_path & space & shell_folder
end repeat
endYour issue is one of symlink support, so it won't matter how you create the symlinks.
First off, which version of Windows are you running?
Only later versions of Windows (Win7 and, I think Vista) support symlinks, so if you're using anything earlier it won't work.
Secondly, if you're pointing to a network volume then the target paths have to match, and that's likely to be a problem in cross-platform environments. That's because the symlink file really just contains the path to the target and your paths may be different on each OS.
For example, On your Mac the sharepoint might be mounted at /Volumes/server and your file might be at /path/file on that share.
So your symlink file will contain '/Volumes/server/path/file'
No Windows system is going to be able to follow that path since disks aren't mounted under /Volumes. You would either have to know that share's current mount point or use a Windows path of the form \\server\share\path\file but that latter form won't work on non-Windows systems.
So the short answer is that you probably have to create two sets of links, one for the Windows users and one for the Macs. There's no simple, universal, cross-platform symlink standard that will do what you want (at least that I'm aware of). -
Invoking a Package.Procedure via bash shell script
Hello All,
I am using the below syntax to call package in a unix shell script, is this right way of calling and checking for errors or is there any other better approach?? kindly suggest.
I am using Oracle 11g & Linux OS, SQL*Plus: Release 11.2.0.3.0 Production
RETVAL=`sqlplus -s FCSDWH_STG/${DBSTG}@${DBSRC} <<EOF
EXEC FCSDWH_STG.FCA_HASH_TOTALS_PKG.HASH_TOTALS_COMPUTE(${PROVIDER},${UNINUM},${EXTRACT_DT},${VER_NUM});
EOF`
if [ `echo ${RETVAL} | egrep "ERROR"` ]
then
logit "Error While Generating The SQLPLUS Output File, Please Check"
exit 1
else
logit "SQLPLUS Output File Has Been Generated Successfully"
fiThanks much.Ariean wrote:
I am testing the same above functionality with the below sample procedure, and I am purposefully making it compile erroneous with "dbms_output.put_lin" just for sake of testing.
create or replace
procedure today_is as
begin
dbms_output.put_lin('Today is : ' || to_char(sysdate,'DL'));
end today_is;This is sample shell script "test.sh" I am using
#!/bin/bash
RETVAL=`sqlplus -s FCSDWH_STG/FCSDWH_STG@dwdev <<EOF
set termout off
exec today_is;
EOF`
echo "start here"
echo ${RETVAL}
echo "end here"
if [ `echo "$RETVAL" | grep "ERROR"` ]
then
echo "Error While Generating The SQLPLUS Output File, Please Check"
exit 1
else
echo "SQLPLUS Output File Has Been Generated Successfully"
fiBelow is my output
start here
BEGIN today_is; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object FCSDWH_STG.TODAY_IS is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
end here
/home/infrmtca/bin/test.sh: line 8: [: too many arguments
SQLPLUS Output File Has Been Generated SuccessfullyI don't understand why it is printing "SQLPLUS Output File Has Been Generated Successfully" though it errored out.Because statements within backquotes are executed before the statement calling the backquote. The [ command has too many arguments coming from the echo and grep. You might put just that test part of the script in it's own little script and test it, it seems to say that whether there is an ERROR in $RETVAL or not. You might need to man test and see if you need a -z argument or something.
>
Edited by: Ariean on May 15, 2013 10:08 AM
Edited by: Ariean on May 15, 2013 10:16 AM -
Starting Java Program with a bash Shell script
Hi !
I know this is a Linux query but I am putting it on this site to get different answers.
I want to start my Java program with a shell script. Can anybody give me a proper script to start my Java program?
I am using RH Linux 7.3 and JDK 1.4.
Can I start the Java program without starting the terminal? Just like the Sun One Studio4 'runide.sh' script.
Please help.
Bye Niteenassuming you have your PATH and CLASSPATH variables set correctly, your script should look like this:
#!/bin/bash
cd <project_dir>
java <class> &
example:
#!/bin/bash
cd ~/projects
java project1.main_package.MainClass &
of course you could add some more elaborated stuff like compiling files before running the program, etc.
if you dont like terminals, try running "nautilus" (it's like Windows Explorer). i never use nautilus (especially for running scripts), so i cant guarantee it will work, although i dont see why it shouldnt... -
Bash shell scripting in Netware OS
I've been trying to port a reporting script I had put together for out OES Linux servers to run in bash on the Netware OS servers. I've been having a few issues with bash thought, and was wondering if the issues I'm running into are just limitations of the OS, or if maybe it is handeled differently in the Netware OS implementation of bash.
Also, another thing to note is I'm testing this on Netware 6.5 sp 8
variables in scripts:
ex. in linux this would work
$variable = `df -h`
echo $variable
for some reason it appears that the variable is hanging up bash in netware and the command just fails.
the other issue I've been having is if I want to string a few commands together with specific commands:
ex:
volumes |grep -i vol1
this seems to hang up the whole server. I'm able to do this with other commands, but when I use volumes, I got an error " BASH: cannot duplicate fd 6 to fd 0: bad file number"
this however isn't as big a deal as not being able to work with variables...
has anyone else tried this that might be able to help?-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> ex. in linux this would work $variable = `df -h`
Um............. no, it wouldn't. First, you would not have a dollar
sign at the beginning; second, no spaces around equals signs. Try the
following:
variable=`df -h`
Better yet, try something really simple:
variable=testvalue
echo $variable
Also keep in mind that some commands, I think volumes included, do not
run normally within bash. If you want output from things like that you
should probably get the contents to a file first and then grep against that.
- From my own minimal experience with bash on NetWare also beware of
processes that run forever (find, for example, on an entire large
volume) as things like Ctrl+C do not seem to interrupt them well.
It may help if you tell us what you're really trying to do. There may
be better ways to pull this off.
Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJP7LfoAAoJEF+XTK08PnB5560P/314qw9tUXO5z/BVVhupV7kI
ZzSi6u2JF6PeRIEPey0/O+jQ/i4aRs3AVWzmn+ykyk16JrFpqd4aJlOg3c0VBlYs
/56p9u18cPbROJteF44HQC6YKwrBEjy39a4PK0cx4nTJbX9qcLz EQKst7VdvtTE5
MeQJ3pifkOfMtKHEZPpagGyXC5vlTZpjj/CsQu8nwUb7TBlJ21o0OOhfY7P0G6HX
E8o/qvCBTlP5PXQVfqIi+vwuYAb0pK7iUIHACwwd1P/cGSI7bA8Bp1oFz3auzwSh
99RdGj7ZXlCjFKqpehuUE54R3b7+9njc+2eNxiaBp8jvWrn5ag 8VTQwG884zHE4n
qW+p5tSdYbXe2LktorweTU9MhHZj/pLanE1ym8iSnk+6DTYZI8lQieLRs9LUJrlp
cNFXh9Jxul/zGmdkoY89ddZHrDCHVRfUnsXmNDjfS5XqY55diCFKMYjM0BU5m rmC
5tlk6EPSAFK/102e7pSpn4DWCw1WYhkwS68NuUIb/6oGHTJHo+GBCDfakLOHMhEd
b/OvQX6EHRyo+w0Kj+DY1Ny4amViVYjy0Cahhv7L7lZ1hQTVuQBl CzNDSBuKH+8m
sfdvTmrmHU/0j6ewtMvoB/RkLmebfhYMziFZRnahxYVJUXpejV2INzhEGC8wg84P
I6tCX1NT0jvgP4FSf4Xv
=Ux8a
-----END PGP SIGNATURE----- -
Executing a unix kill from APEX or running a bash shell script from Apex
I'm writing a browser based app that I would like to write with APEX and that will identify and kill a very specific process name and Unix user name combo.
I can identify the unix PID in V$SESSION if I want so, I know how to to the first part (identify the process/PID).
How can an APEX app execute the Linux kill command? I'm not seeing anyway to host out of APEX. I was looking for something like that where you create processes...
Please provide only suggestions on how to do this from APEX. I know there are lots of other ways (CGI from Apache etc.).I have this working, though it's kinda clunky.
Apex calls Oracle Stored Procedure which calls Java stored procedure which defines a class that runs exec to execute an OS command, and waits for the return value.
The DBA had to grant special permission for my oracle schema to execute the script name that is passed into the Java.
Others may have a better way of doing this. -
Sqlplus and unix (bash) shell scripting
Hi,
I'm extracting some information from a DB and then "spooling" it to a file. So far so good.
The problem is that the records I get are not like what they look like when I run the stuff in sqlplus. Instead, the spooled file has alot of weird spaces and tabs in between and does not properly separate between the different rows.
Does anyone have any tips on how to do this?
Note: The datatype of the field I'm retrieving is "long". I've set linesize, pagesize and long to 1000.Hi!
Try also to change SQL*Plus settings, i.e. SET LINESIZE 1000 (or whatever the most long line of your report could be), then TRIMSPOOL ON, TRIMOUT ON.
Regards,
Andrew Velitchko
BrainBench MVP for Developer/2000
http://www.brainbench.com -
Startup shell script help for newbie?
New to UNIX (linux)... need the bash shell script commands for my r.c local file to start my services when server boots.
I got my ds, dps and admin server in their respective /opt directories. I need the shell commands to have these start. Of course I can start them manually but when I try a line like this in a script, it doesnt work:
./var/opt/sun/directory-server/slapd-dsserver/start-dsserver
Some path problem or dot thing?There are a few other things you may want to consider, such as what the default browser is, are tabs being used, is the page loaded yet, etc, but Safari has a do javascript command in it's scripting dictionary. The following script will open a new document and run your specified javascript, or you can go to their NPR Program Stream Page and download a playlist that will run directly from iTunes.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 335px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into the Script Editor">
set my_script to "NPR.Player.openPlayer(2, 0, '03-21-2008', NPR.Player.Action.PLAY_NOW, NPR.Player.Type.PROGRAM, NPR.Player.Mode.LIVE)"
tell application "Safari"
activate
set the URL of the front document to "http://www.npr.org/"
if my page_loaded(20) is false then error numner - 128 -- page not loaded in time
do JavaScript my_script in document 1
end tell
on page_loaded(timeout_value) -- from http://www.apple.com/applescript/archive/safari/jscript.01.html
delay 2
repeat with i from 1 to the timeout_value
tell application "Safari"
if (do JavaScript "document.readyState" in document 1) is "complete" then
return true
else if i is the timeout_value then
return false
else
delay 1
end if
end tell
end repeat
return false
end page_loaded
</pre> -
what is shell scripting? get me notes of that... how shell scripting is related to sql or plsql?
shell scripting is the process of creating programs which are able to execute using a shell.
a shell is the program you use when you are logged in to a linux (or unix) system via ssh (or if you are outdated by 10 years: telnet).
there are much shells, traditionally, unix system use the bourne shell (visible as sh most of the time), the kornshell (ksh) and c-shell (csh) extended the bourne shell functionality. nowadays there are very much shells, most linux systems use the bourne again shell (bash). the bash shell is available for most linux/unix systems, I always advise to use it on any system, so the shell functions the same on all platforms.
if you want to know more about shell scripting, use "google". the website of google is http://www.google.com, and usage is free. use the keywords "bash shell scripting". -
I have a file with passwd format.I made a script for this file that is working as I wanted it to work.I have a list of options and each time I give an option,the script is doing something(for example,if I press "b" it makes something and if I press "a" it makes something else).All the results are an output from the file.
My question is how can I create a GUI in java for this script.For example if I want the script to do what it would do if I pressed the "a" button on my keyboard,but not by pressing "a",but by choosing from a drop down list or some other graphical feature(by ticking a check box,clicking a button etc).Can I do this with java?
LazarosHi,
I understand you can create a Java Swing gui for a bash shell script which takes both complex input and writes output to the stdout & files, to be specific. Is that correct?
If yes, could you give a simple example. Say for the following shell script.
#!/bin/sh
printf "Enter input\n"
i=0
while [ $i -ne 1 ]; do
read $inputVar
if [ "$inputVar" == "y" ]; then
printf "You typed yes\n"
i=1
elif [ "$inputVar" == "y" ]; then
printf "you typed no\n"
i=1
else
printf "Enter a valid character\n"
i=0
fi
done
Could you also point to some URL's which might help? Googling for "Java Gui for shell script" returns this as the first page, others dont really help. Googling "GUI for shell script" returns all other gui toolkits for xes but thats not what I want. I want a cross platform (nixes, Win*, MacOS* ) gui for a shell script ( which I plan to run using cygwin etc).
TIA
Vinod -
Mount script for ext2 - mixing applescript and shell script
Hello
i want to do a .app using the ScriptEditor to get my external usb-disc mounted.
I tried ExtFS Manager before, but was not as happy with it.
so the basic idea is some kind of mixture of apple script and bash-shell script, but im not sure how to combine it.
shell script:
#!/bin/sh
sudo kextload /Library/Extensions/ext2fs.kext
mkdir ~/usb_music/
sudo mount -t ext2 -o nosuid,w,m=777,user /dev/disk1s5 ~/usb_music/
sudo chmod a+rwx ~/usb_music/
apple-script:
on run
try
do shell script ""
end try
end run
any ideas how to get it combined and working ?
best regards
fidel
MacBookPro 15,4" 1,83 GHz Mac OS X (10.4.8)is there a way to implement it in a way that normal users can work with sudo to mount the drive ?
kextload requires superuser privileges, so at some point some part of your script is going to need to run with elevated privileges.
It is possible to configure sudo to allow non-admins to run any other commands. You could either allow non-admins to to run kextload or, preferably, allow them to run your shell script.
man sudoers will give you the details on how to configure sudo to do this, which might be as simple as:
<pre class=command>ALL ALL=(ALL) /usr/local/bin/myscript</pre>
This will allow all users to run /usr/local/bin/myscript as root. -
Trouble running automator shell script
This is probably going to be an really simple fix, but I'm have trouble building an automator service that runs a bash shell script. All of the elements of the script work fine when plugged into shell, but for some reason the automator service is failing to run. The script calls ffmpeg to convert an audio file:
for f in "$@"
do
fn="${f%%.*}"
/Users/aa/Applications/ffmpeg/ffmpeg -i "$f" -acodec libmp3lame -q:a 7 -ar 8000 -ac 1 "$fn.mp3"
done
The script runs fine without the ffmpeg command, and the ffmpeg command runs fine in the terminal on its own. Where's the error coming from?
Thanks!The first is what I'm getting from the bash terminal execution, the second from automator. I'm accenting the differences I see. Thanks for the help!
----bash----------------------------------------
drwxr-xr-x@ 67 aa staff - 2278 Apr 6 07:42 .
com.apple.progress.fractionCompleted 14
0: group:everyone deny delete
uid=501(aa) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81( _appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),398(c om.apple.access_screensharing),399(com.apple.access_ssh)
0
-bash
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/x9/y4r_w7gj4_j_3wkfxn6s6fqm0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.oSzc5cau0v/Render
TERM_PROGRAM_VERSION=343.6
TERM_SESSION_ID=AF09D92C-2CB4-4069-A172-0DE12EB226BD
USER=aa
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.RFhFIs94Ad/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/Applications/anaconda/bin:/Applications/anaconda/bin:/Applications/anacond a/bin:/Users/aa/anaconda/bin:/Applications/anaconda/bin:/Applications/anaconda/b in:/Applications/anaconda/bin:/Applications/anaconda/bin:/Library/Frameworks/Pyt hon.framework/Versions/3.4/bin:/Applications/anaconda/bin:/Users/aa/anaconda/bin :/Applications/Anaconda/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbi n:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/texbin
PWD=/Users/aa
LANG=en_US.UTF-8
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/aa
LOGNAME=aa
DISPLAY=/private/tmp/com.apple.launchd.YewceoE69R/org.macosforge.xquartz:0
_=/usr/bin/printenv
----automator----------------------------------------
/Users/aa
drwxr-xr-x@ 66 aa staff - 2244 Apr 6 07:42 .
com.apple.progress.fractionCompleted 14
0: group:everyone deny delete
uid=501(aa) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81( _appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),398(c om.apple.access_screensharing),399(com.apple.access_ssh)
0
SHELL=/bin/bash
TMPDIR=/var/folders/x9/y4r_w7gj4_j_3wkfxn6s6fqm0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.oSzc5cau0v/Render
USER=aa
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.RFhFIs94Ad/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PWD=/Users/aa
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/aa
LOGNAME=aa
DISPLAY=/private/tmp/com.apple.launchd.YewceoE69R/org.macosforge.xquartz:0
_=/usr/bin/printenv
Maybe you are looking for
-
How can I delete a previously published app from my dashboard?
I have an app on my Windows Store dashboard that was in the store, but I unpublished it and I'll never publish the app again. How can I delete the app from my dashboard? I've read answers on simular questions that an app can't be deleted, but I reall
-
How to process a simple notepad file and extract something from it not all.
I am sending the text file from html page to servlet and i want to do something with that text file and the result would be in excel. for example if my file contains: Notepad file Contains: CP STATE MAU SB SBSTATE NRM B WO and i want only SB,SBSTATE
-
Portal eventing: hiding iView?
Hi all, I've made 2 portal components: a search iView and a result iView. When I enter searchcriteria in the search iView and click the search button, the result iView shows me the results (via EPCM event). Now, I'm wondering if it's possible to hide
-
WEB AS Java 640 and Sap Gateway
Hello, I have installed a J2EE 640 in HA for internet sales (ISA) in the following scenario: SCS in failover switch group and a Central Instance on node A, Dialogue Instance node B. Then I installed a SAP Gateway on node B for TREX 6.0, but I'm havin
-
Hi all. I have an apex 4.0.2 page with two regions: HTML Region with a group of itens and manual tabular form region(using apex_item). On the page i have three PLSQL processes : -The first inserts values in a table, using item values from the HTML re