Shell Scripts: "Open [ALL] With" Emacs
Hi All,
I'm trying to figure out a way to open ALL shell scripts (for which I use the extension ".sh") with emacs (launched in the terminal) by default.
I've made some progress towards this goal, but am stuck on the last step. Here's what I've done:
[1] I copied an Apple Script (from here: http://hints.macworld.com/article.php?story=20031027142625782) to create an Application (which I've called "Emacs_open_with.app"), that when launched with a file, will open it in emacs in the terminal.
[2] I can make Emacs_open_with.app the default launch app for a individual shell script by right-clicking -> Open With -> Other... -> Emacs_open_with.app (+ check the box "Always Open With). However, doing this will only make it the default app for that single shell script, not for all of them, as I desire.
[3] Normally, one can associate an application with a file extension, such that any file with that extension will be launched by default by this associated application, by: Right-clicking a file -> Get Info -> Open With -> Other... -> [DESIRED APP] (+ check the box "Always Open With) -> Change All... -> Click Continue when the pop-up appears which asks "Are you sure you want to change all similar documents to open with the application...". However, this does NOT work for Emacs_open_with.app; as soon as I click continue, the drop-down menu which I had used to select "Emacs_open_with.app" changes back to another, different Application.
Any idea about how best to tackle this problem? Thanks for your help!
Ilmari Aalto wrote:
Hi Darth,
Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
Cheers,
IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all...
Similar Messages
-
Modify shell script to work with other folders
i am trying to modify a shell script that sorts files in a course folder into sub folders by month. I have a shell script that works, but when i try to modify it for another course folder it quits working. can someone let me know what i am doing wrong?
the working shell script:
do shell script "
for f in \"$HOME/Desktop/DWI Annual Report/\"*
do if [ ! -d \"$f\" ]; then
x=\"${f%%.*}\"
i=$((${#x}-3))
if [ -d \"$HOME/Desktop/DWI monthly/${f:$i:3}\" ]; then
mv \"$f\" \"$HOME/Desktop/DWI monthly/${f:$i:3}\"
fi
fi
done"
the nonworking modified script:
do shell script "
for f in \"$HOME/Desktop/DOEP Annual Report/\"*
do
if [ ! -d \"$f\" ]; then
x=\"${f%%.*}\"
i=$((${#x}-3))
if [ -d \"$HOME/Desktop/DOEP monthly/${f:$i:3}\" ]; then
mv \"$f\" \"$HOME/Desktop/DOEP monthly/${f:$i:3}\"
fi
fi
done"ok here is the applescript that works.
property total_student : 1
tell application "Finder"
set master_path to alias "Users:macbook:Desktop:DWI Annual Report:Annual Report.xlsx"
set filesWithDWI to get every file of folder ((path to desktop folder) & "DWI Annual Report" as string) whose name contains "DWI"
repeat with f in filesWithDWI
my transfer_data(f, master_path)
end repeat
end tell
on transfer_data(child_path, master_path)
tell application "Microsoft Excel"
set child_book to (open workbook workbook file name (child_path as string))
set child_doc to worksheet 1 of child_book
set master to worksheet "sheet 1" of (open workbook workbook file name (master_path as string))
set num to 15 --All lists start at index 12 or later, I'm putting 10 to be safe
set students to {}
tell child_doc --grab values from child document
repeat until (value of cell (("A" & num) as string)) is 1
set num to num + 1
end repeat
repeat until (value of cell (("B" & num) as string)) is ""
set end of students to {namevalue of cell (("B" & num) as string)), driver_idvalue of cell (("C" & num) as string)), DOBvalue of cell (("D" & num) as string)), Ref_Recvalue of cell (("I" & num) as string)), pre_testvalue of cell (("J" & num) as string)), post_testvalue of cell (("K" & num) as string)), cert_idvalue of cell (("L" & num) as string))}
set num to num + 1
end repeat
set startdate to range "C7"
set classlocation to range "C11"
set instructor to range "H7"
end tell
tell master
set num to 7
log (value of cell (("B" & num) as string))
repeat until (value of cell (("B" & num) as string)) is ""
set num to num + 1
end repeat
repeat with student in students
set value of cell (("A" & num) as string) to total_student
set value of cell (("B" & num) as string) to name of student
set value of cell (("C" & num) as string) to driver_id of student
set value of cell (("D" & num) as string) to DOB of student
set value of cell (("H" & num) as string) to pre_test of student
set value of cell (("I" & num) as string) to post_test of student
set value of cell (("J" & num) as string) to cert_id of student
set value of cell (("f" & num) as string) to startdate
set value of cell (("E" & num) as string) to classlocation
set value of cell (("G" & num) as string) to instructor
set value of cell (("K" & num) as string) to Ref_Rec of student
set num to num + 1
set total_student to total_student + 1
end repeat
end tell
save child_book
close child_book
save active workbook in master_path
close active workbook
end tell
end transfer_data
do shell script "
for f in \"$HOME/Desktop/DWI Annual Report/\"*
do
if [ ! -d \"$f\" ]; then
x=\"${f%%.*}\"
i=$((${#x}-3))
if [ -d \"$HOME/Desktop/DWI monthly/${f:$i:3}\" ]; then
mv \"$f\" \"$HOME/Desktop/DWI monthly/${f:$i:3}\"
fi
fi
done"
It takes the class rosters and copies the information from the class roster to the annual report and then moves the file to the monthly folder and files it in the appropriate months folder based on the last three letters of the file name. -
UDM and shell scripts and working with the ENVIRONMENT variable options
In Userdefined metrics you have the ability to pass envronment variables.
I was going to send
DIR=/db/db05/oradata/ORCL/hot
How to handle whats passed to the shell script?
It passes $1 as {DIR=/db/db05/oradata/ORCL/hot}
yes with the brackets. Here I figured it would simply set the DIR environment variable.
Any cool tricks to work with this mess?
Is it meant for perl scripts instead?
Daryl.Ilmari Aalto wrote:
Hi Darth,
Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
Cheers,
IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all... -
JSP Shell Script Output (All At Once Vs Line By Line)
I have no problem calling a shell script and then displaying that output on a web page.
However, I would like to display the output as the script executes (I want to print the output line by line as it happens), rather than waiting for the script to completely finish and then display the whole output all at once. The script checks a large database and takes about 10 minutes to run. I don't want to stare at a blank screen during that time, but of course want to watch it's progress on the display (when I run the script directly I print out status to the screen).
Can someone point me in the right direction on how to do this?
-jsaspoBump...
Anyone? -
Script: Open all linked docs in *new* window
Can anybody help? I have a pdf document that will need to have 2000+ links to other documents...and I need to have each link open in a *new* window (by default, they open in the exisitng window). We obviously don't want to have to individually set each link's Properties to "open in new window"...
Is there a script I can add to the main (parent) pdf doc to make this happen for all links the user clicks on from the main doc? The kicker is that we can't expect the end user to be able to fool with the Preferences or anything like that...in addition, we assume the user may be viewing in either Acrobat or Acrobat Reader in the corporate environment.
Alternately, a script to automatically show the "previous view" and "next view" arrows, without having the user have to do anything, might work. The absence of those arrows in the default view (starting w Acro 8?) is why we've had to go with the "open in new window" idea. We are dealing with non-tech-savvy users, so we don't want them to have to know keyboard shortcuts or set Preferences...
Thanks so much!!!
BradfordAbsolutely, thanks! I will try to create a variable to store -- and later, restore -- that. Since we have about a zillion links, changing each link would be no fun at all! Is there an issue with trying to evaluate the setting and store the variable from a "on page 1 open" action, and being able to access the variable's value from the "DocumentWillClose" action? (and apologies for any capitalization, etc., issues)
Do I somehow need to declare the variable to be global, or do I need to have the initial actions happen from an "on document open" event? (I don't see such an event as being an available option)...
Any code snippet(s) far a similar situation that you could point me towards...?
Thanks!
Bradford -
UNIX path AND Do shell script path with spaces
I am trying to building a interface with buttons to execute shell commands when the button is pressed. Below press button execute code.
I am new to AppleScript and Xcode and Interface builder. I have read different post referencing spaces but I still don't understand.
THIS COMMAND DOESN'T WORK IT'S SOMETHING TO DO WITH SPACES.
How would I fix this to work.
on clicked theObject
do shell script "rm /Library/Preferences/com.netopia.netOctopus\ Agent.preferences"
end clicked
This works (Below) no spaces in the path
on clicked theObject
do shell script "open /System/Library/PreferencePanes/SharingPref.prefPane/"
end clicked
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.6)
ALL Mac OS X (10.4.8)
ALL Mac OS X (10.4.8)Camelot's explanation was good, but you don't seem to get it, so I'll take a crack at explaining as well.
First off, you need to understand what "do shell script" does and does not do. "do shell script" takes a string from AppleScript and passes it to a shell interpreter. It does not check in advance that this string makes sense. (That is impossible to do, in fact.) It just passes it along. The shell interpreter then converts the string into a command, or series of commands, and attempts to run them.
In AppleScript, quotation marks around something make that something a string. So, for example:
"rm "
is a string containing a letter r, a letter m, and then a space. Some commands can also return a string, which can then be stored in a named variable, as for example:
set a_variable to (the text returned of display dialog "Hi!" default answer "Some text")
When you wish to put two strings together in AppleScript, you use the & operator, as in:
"String 1" & "String 2"
In this example, there is no space at the end of the first string, and none at the beginning of the second, so the result is:
"String 1String 2"
All clear so far?
When a shell interpreter attempts to convert a string into commands, it has to split the string into pieces. A space signifies a break between pieces. In order to put a space into a single item, you can do a number of things. You can put the whole item in quotation marks (single or double), which is known as "quoting":
'/A/Path/With/A Space'
or you can put a backslash before the space, which is known as "escaping":
/A/Path/With/A\ Space
You can combine quoting and escaping if you do it right. For example, the backslash also lets you use a quotation mark inside a single item which is quoted:
"/A/Path/With/A Space/And/A\"Quotation/Mark"
There are further rules and substitutions that sometimes border on the arcane.
In order to simplify things, Apple created the command "the quoted form of". This command takes a string and returns a new string which is properly set up so that it will be just one item when split up for the command line. It will add quotation marks, backslashes, or whatever.
So, to put things together:
"rm " & the quoted form of thePath
is a way of saying to AppleScript "take the string in the variable named thePath, and quote it for the command line; then stick it on the end of a string containing an r, an m, and a space."
When you pass this to "do shell script", it will break things up in such a way that it hands thePath to the rm command, which will attempt to remove whatever is represented by thePath. (Adding the "-r" in there just tells the rm command "if this is a directory, get rid of it and all its contents". Otherwise rm will complain if the item is a directory.)
I think, however, you may just have the path wrong. In one of the spots where you gave the POSIX path, it had a backslash (\) at the end instead of a forward slash (/). As Camelot says, a forward slash means that the item is a directory and not a plain file. But if you really meant the backslash, it suggests that the item is a plain file, but has a space at the end (or some other character that mystifies the command line). It's an escape.
Try making a new script in Script Editor which says
">" & (the POSIX path of (choose file)) & "<" at the end, that's the culprit.
(And if it won't let you select the file when you run the script, it means that the item is actually a folder.) -
Automator shell script won't run
Hi,
I'm putting together a little Automator app that opens whenever I double-click on an .exe file and opens that file with wine. So far, however, I've had little luck. I've created a shell script automator app with the following script:
for f in "$@"
do
/usr/local/bin/wine "$f" &
done
Outside of Automator the script works just fine. However, as an Automator app it doesn't work at all; nothing happens, even though Automator tells me that that the workflow was successfully completely. What am I doing wrong?
Thanks,
AlexAutomator uses /bin/bash as the shell.
Running your script interactive has a different environment from running under Automator. For one thing, stdin/stdout/stderr are pointing to a tty (actually a pseudo device /dev/pty). Perhaps this is affecting how Wine us behaving.
Other issues might be where your current working directory is located, or some environment variable (such as PATH) that is not the same under Automator that exists when running interactively.
You might try capturing things like
( printenv
pwd
id -a
echo "\$# $#"
) >/tmp/automator.environment -
How do you make like a dialogue box appear when I am using sudo scripts?
It might be helpful if you could provide a bit more detail about the goal. Your original question asked about an actual password dialogue, but if there is someone there to enter an "admin" password, why can't they use the "Accounts" pref pane? For example, I could see this being the case if the current account was "managed" with access to secure pref panes restricted, but a few posts later, your example of 'sudo passwd admin' implies that it is an "admin" account's password that is to be changed. But why would an "admin" want to change their password from a "managed" account... Without knowing what exactly the goal is, it is difficult to provide meaningful suggestions.
But speaking more generally, changing 'do shell script "sudo ..."' to 'tell application "Terminal" to do script "sudo ..."' should cause a "Terminal" window to open, with a password prompt in a command line interface.
Alternatively, rather than using 'sudo' in "do shell script" statements, it is possible to use "with administrator privileges" to avoid the need for the interactive password (and don't combine 'sudo' with "with administrative privileges" because it is apparently insecure).
http://developer.apple.com/technotes/tn2002/tn2065.html
To incorporate a password dialog into a "do shell script ... with administrative privileges" statement, you could use Tiger's new "hidden answer" option in the standard "display dialog" statement. While this does obscure the password, I don't think it is particularly secure either.
Finally, 'passwd' also requires an interactive password, whereas 'dscl' doesn't with some options, (nor does 'pwpolicy' but that won't work unless password policy options are enabled), so 'dscl' might be more suitable in a script. However, options where the password is provided in the command are also less secure since theoretically the password could be viewed in plain text by someone running 'ps' at the right time... -
How to get this script to work with different browser
Do you guys know how to get this script to work with mozilla firefox?
do shell script "open -a safari 'https://login.binck.nl/klanten/Login.aspx?ReturnUrl=%2fklanten%2fdefault.aspx'"
tell application "Safari"
activate
tell document 1
repeat until ((do JavaScript "location.host") is "login.binck.nl")
delay 1
end repeat
do JavaScript"document.getElementById('ctl00_Content_Gebruikersnaam').value='sim';document.ge tElementById('ctl00_Content_Wachtwoord').value='password';window.open(document. g etElementById('ctl00_Content_LoginButton').href, '_self', 'true');"
end tell
end tell
Thank you so much in advance:)That isn't possible. Firefox's AppleScript dictionary doesn't contain anything which can be used to manage JavaScripts.
(63741) -
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 -
Running Plsql procedure using shell script
Dear All,
Dear All,
I have to generate reports weekly by using a plsql procedure.
For Exapmle : My Proc name is Weekly_report(i number).
Here i is the argument for which i need to run the proc 7 times as follows
exec weekly_report(1)
exec weekly_report(2)
exec weekly_report(3)
exec weekly_report(4)
exec weekly_report(5)
exec weekly_report(6)
exec weekly_report(7)
I need to run them parallely at a time so that time taken will be less. Is there any way doing this through shell script.
Thanks in asdvance.damorgan wrote:
I can't think of anything in the Oracle world left in the dustbin of history I miss less than shell scripts.
Why work in another language, why work in a tool that is non-portable, why have to deal with SysAdmins when dbms_scheduler is many times more capable?
Definitely DBMS_SCHEDULER. Shell scripting is obsolete with perhaps only a few very rare exceptions.+1: shell scripts suck.
DBMS_Scheduler allows you to setup the report procedures as programs that are executed at the same time in a single job (as steps in a scheduler chain). you can also setup email confirmation based on them successfully completing. All good stuff and not difficult to do. -
Rwcgi60 on UNIX needs shell script ?
I am trying out Reports 6i on a Linux box.
Using Apache Webserver, I have mapped all the virtual directories with execute permission.
When I call rwcgi60 through the browser, I get the following output
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<CENTER><H1>
</CENTER></H1>
<BR></BODY>
</HTML>
But when i call a shell script (which in turn calls rwcgi60) through the browser, i get some output.
The shell script exports all the environment specific to Oracle Reports and calls rwcgi60.
Is the CGI intended to be called from a script file ? If no, what other configuration is necessary ?
Thanks.I am having exactly the same problem on Solaris. The information I have shoehorned out of support so far is that you do need a shell script to make this work. I have followed these instructions but am still having problems. The document which details this bug is unpublished by Oracle so I only got extracts. Detailed below.....if you do have success with this please let me know as I am tearing my hair out.
REPORTS60_SERVER
1. The REPORTS60_SERVER file is located in your Oracle_Home and is used to
start the Report Server.
2. You may need to modify this file for variables such as DISPLAY, TNS_ADMIN
and the REPORTS60_PATH to fit your environment. @Also, please refer to
@Note: 111548.1 for setting up the TNSNAMES.ORA file.
3. If you are not using a WebDB Listener, you can delete the section which
stops and starts it. However, make sure you have started up your Webserver
Listener.
4. Once this file has been modified, the command to execute it is:
reports60_server start
Shell Script (RUNREP.SH)
1. You will need to create a shell script to run RWCGI60. This shell will then
be called from RUNREP.HTM file. You can name it anything (the example is
called runrep.sh) and needs to include the following:
#!/bin/sh (or which ever shell you want to use)
- ORACLE_HOME="/u03/app/oracle/product/dev6i"; export ORACLE_HOME
- TNS_ADMIN="/u03/app/oracle/product/dev6i/network/admin"; export
TNS_ADMIN
- exec /u03/app/oracle/product/dev6i/tools/web60/cgi/rwcgi60
2. You will need to redefine the ORACLE_HOME and TNS_ADMIN due to BUG:1201156.
3. This script can be located anywhere as far as the Webserver
Listener is
concerned. However, the best place would be in the ORACLE_HOME/tools/web60/
cgi directory for which we already have a virtual name defined in the
listener configuration file.
RUNREP.HTM
1. The RUNREP.HTM file is located in the ORACLE_HOME/tools/web60/html
directory.
2. You will need to modify this file due to the above mentioned Bug.
Go to the function called runReport( ) and for the var cgiexe = "rwcgi60",
replace it with the above shell script.
Example: var cgiexe = "runrep.sh"
3. Next, modify the port number for the Webserver. This file assumes that you
will be using the WebDB listener and is installed on port 8080 (by default).
You will need to find the following and change it to the correct port
number:
<td><input TYPE="TEXT" NAME="WEBPORT" SIZE="4" VALUE="8080"></td>
Change the Port Number to the one your WebServer Listener is on, such as:
7777.
After doing all of the above, you are ready to run a report on the web using
CGI implementation. From the browser run the following URL:
http://your_machine_name:listener_port#/virtual_dir_for_cgi/runrep.htm
This brings up a Template for you to provide the report name. Also change the
parameter values here for the userid/password, port#, and reports_server. -
Test ssh -ND connection in a shell script
I use a web proxy with firefox by setting up this ssh tunnel:
ssh -ND 8080 [email protected]
Is there a shell script way (like with nc) I can test this connection?Hi Bill,
I don't know if I'll be able to provide all of the help I'd like to because I have to get ready to go out of town. You used Fink to install "wget", right? "wget" will do almost anything a browser will do so I can't think of a better way to test from the command line. If you don't have "wget", "curl" will do. Is that what you had in mind? You can probably do it with "telnet" but "wget" understands complex URLs which, to my taste, is an easier way to specify the port.
Gary
~~~~
Lizzie Borden took an axe,
And plunged it deep into the VAX;
Don't you envy people who
Do all the things YOU want to do? -
[SOLVED] Sudo Ranger does not open files with VIM
I am using ranger as my file manager. And sometimes I run it with sudo. But then it want's to open all with nano. Even tough the environment variables (EDITOR & VISUAL) are set to vim.
Maybe it hast something to do with /bin/sh - but when that is the case, how do I change the default behaviour of /bin/sh?
Last edited by natepad (2015-04-02 16:07:36)Sure you can. As the sudoers man page describes, the env_reset option is on by default. You could use the env_keep options. Or use the -E flag for sudo. Or....
http://www.sudo.ws/sudo/man/1.8.13/sudo.man.html
http://www.sudo.ws/sudo/man/1.8.13/sudoers.man.html -
Power Shell Script to Initiate Billing Determinants Calculations
Hi All,
I'm New to CC&B, i have a problem when i try to initiate the BD Calc thru Power shell script for "ALL" Accounts, at the same time i'm able to succeed for single account. Did any one faced this problem ?
Any advise?
btw, i use Win2008R2 server (x64) | MDM 1.6.1.2 | PShell v1.0
- Nandawbadmin start systemstatebackup -backupTarget:$backdir -[quiet]"[quiet]"? I guess you should remove the bracketswbadmin start systemstatebackup -backupTarget:$backdir -quiet
Maybe you are looking for
-
EDI Order Confirmation Question : attach additional .PDF file
Hello, Is it possible to attach to an Order confirmation (for customer standard order) an additional pdf.file automatically? If yes, what are the necessary steps needed? Hoping for reply. Many thanks !
-
How to copy the positions and their relationships of one org.unit to other
f there about 20 organization units among which 6 org.units have same positions and same relationships ,i know that we can create one org.units and their relationships among 6 similar org.units and then copy the same position and relationships to oth
-
Unable to connect as a formal agent to a Response Group after Migration to Lync 2013
We are in the process of migrating our Lync 2010 servers to Lync 2013. Everything seems to go well, but problems started to appear after we migrated the Lync 2010 response groups to Lync 2013. Now only those groups with informal agents work. All the
-
How to extract data from MS-Access
Hi Experts, I have a scenario where I have to extract data from MS-Access. I'm developing a ABAP component. I looking for help in writing query for data extraction. I have no idea of extracting data form MS-Access. Have worked on BAPI and SAP tables
-
How to make footnotes/endnotes in Turabian format?
I am trying to finish my final essay paper for my history class and I am finding it a little difficult to change my Footnotes/endnotes in Turabian format. I have tried looking on the inspector as where most changes are made for an essay, but I can no