Syntax for inserting a number in a shell script in applescript
who can help me correct this code?
the user will enter a number in a dialog box, and this variable will replace the 7 in the shell script.
i cant seem to keep the syntax right, i keep erroring out.
if days_back is "" then
set dialog_1 to display dialog "please enter a number " default answer ""
set the days_back to the text returned of dialog_1
end if
set the_result to (do shell script "mdfind -onlyin '/Volumes/Volume1' 'kMDItemFSContentChangeDate >=$time.today(-7)'")
display dialog the_result
Try using:
if days_back is "" then
set dialog_1 to display dialog "please enter a number " default answer ""
set the days_back to the text returned of dialog_1
end if
do shell script ("mdfind -onlyin '/Volumes/Volume1' 'kMDItemFSContentChangeDate >=$time.today(-" & days_back & ")'")
display dialog the result
(54186)
Similar Messages
-
Syntax for inserting a single field
hai
can u please tell me what is the syntax for inserting a single field in ztable.
Regards,
N.selvamuthukumar.inserting a single field doesnt make sense if table has more dan one primary keys.
The syntax is
INSERT INTO TABLE VALUES WA_TABLE.
where wa_table is of type ztable. -
How to do multiple shell scripts in AppleScript
I got some solutions from previous posts on how to run sudo in Applescript, but there is still some minor syntax issues when I try to get to the destination directory. Usually in shell script I just type
cd directory-destination
in several lines to batch process those commands, but when I work with applescript, if I do do shell script for every "cd" command, instead of getting an overall result, I would get intermediate results individually.
I read doc and learned that there might be a way to put commands together by using the & sign?
Message was edited by: ttbackAn individual do shell script command runs in its own shell, so to perform multiple commands within that shell you need to combine them into a single statement. You can use the ampersand '&' operator to concatenate text strings, and the semicolon ';' to separate the commands, for example:set theFolder to "/Applications"
do shell script "cd " & theFolder & "; ls -l ."See the technical note do shell script in AppleScript. -
How to retrive ip address of connected device in shell script or applescript
Hi all,
From Mac PC, how to get ip address of connected device in shell script or applescript.
there is any way to launch an app on ipad in shell script or applescript.
thank you in advance for your help
MickaelHi all,
From Mac PC, how to get ip address of connected device in shell script or applescript.
there is any way to launch an app on ipad in shell script or applescript.
thank you in advance for your help
Mickael -
Need a sample file for IDQ parameter file and a Shell script to execute it from command line
Hello,The parameter file itself is generated from cmd line using infacmd command and it automatically creates the parameters inside it based on the parameters created inside the mapping and the workflow. So, even if one provides you a paramtere file for IDQ, it might fail as your workflow definition and its paramters would be different. Thanks,K
Hi all My project migrated from Power Center to IDQ developer and I had to move all my mappings to IDQ developer. I was able to migrate everything except for the parameter files. It seems that the layout and syntax for parameter file is different from Power Center. Is there anyone who can help me out or send me a sample of a parameter file for IDQ? As well as a sample shell script to run the mapping or application from the Command line.This is an urgent need and It will be greatly appreciated. ThanksNaveen Medisetti
-
I want this so I can just download anything I want by just having the link and I have made a few things with shell scripts in automator before, just never anything where i need to input a value into the shell script.
Easy:
-
Find & replace part of a string in Numbers using do shell script in AppleScript
Hello,
I would like to set a search-pattern with a wildcard in Applescript to find - for example - the pattern 'Table 1::$*$4' for use in a 'Search & Replace script'
The dollar signs '$' seem to be a bit of problem (refers to fixed values in Numbers & to variables in Shell ...)
Could anyone hand me a solution to this problem?
The end-goal - for now - would be to change the reference to a row-number in a lot of cells (number '4' in the pattern above should finally be replaced by 5, 6, 7, ...)
Thx.Hi,
Here's how to do that:
try
tell application "Numbers" to tell front document to tell active sheet
tell (first table whose selection range's class is range)
set sr to selection range
set f to text returned of (display dialog "Find this in selected cells in Numbers " default answer "" with title "Find-Replace Step 1" buttons {"Cancel", "Next"})
if f = "" then return
set r to text returned of (display dialog "Replace '" & f & "' with " default answer f with title "Find-Replace Step 2")
set {f, r} to my escapeForSED(f, r) -- escape some chars, create back reference for sed
set tc to count cells of sr
tell sr to repeat with i from 1 to tc
tell (cell i) to try
set oVal to formula
if oVal is not missing value then set value to (my find_replace(oVal, f, r))
end try
end repeat
end tell
end tell
on error number n
if n = -128 then return
display dialog "Did you select cells?" buttons {"cancel"} with title "Oops!"
end try
on find_replace(t, f, r)
do shell script "/usr/bin/sed 's~" & f & "~" & r & "~g' <<< " & (quoted form of t)
end find_replace
on escapeForSED(f, r)
set tid to text item delimiters
set text item delimiters to "*" -- the wildcard
set tc1 to count (text items of f)
set tc2 to count (text items of r)
set text item delimiters to tid
if (tc1 - tc2) < 0 then
display alert "The number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string."
error -128
end if
-- escape search string, and create back reference for each wildcard (the wildcard is a dot in sed) --> \\(.\\)
set f to do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g;s/\\*/\\\\(.\\\\)/g' <<<" & quoted form of f
-- escape the replacement string, Perl replace wildcard by two backslash and an incremented integer, to get the back reference --> \\1 \\2
return {f, (do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g' | /usr/bin/perl -pe '$n=1;s/\\*/\"\\\\\" . $n++/ge'<<<" & (quoted form of r))}
end escapeForSED
For what you want to do, you must have the wildcard in the same position in both string. --> find "Table 1::$*$3", replace "Table 1::$*$4"
Important, you can use no wildcard in both (the search string and the replacement string) or you can use any wildcard in the search string with no wildcard in the replacement string).
But, the number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string. -
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 -
I have a program that I run via Terminal, but I don't want a terminal window open while I run it (Just personal preference). I have an applescript set up to run the Terminal command, but the thing is that the command is "on" while the program is running, Is there some way that I can have the command go and then end the script wihtout closing the program? Or am I out of luck and have to have the Terminal window open?
The program I am using is located here http://sites.google.com/site/sc2gears/
Thanks for the help!The program is distributed (according to the docs) as a .command file, so you can get the efect you want like so:
do shell script "/Users/yourname/further/path/Sc2gears-os-x.command &> /dev/null &"
the &> /dev/null tells applescript that you don't care about any output, so it moves on to the next command, and the closing & sets the process up as a standalone. Note:
If the process doesn't close itself automatically you'll need a separate way of doing that
if the process produces output you want to keep, don't use /dev/null - use an appropriate file path
(obviously) '/Users/yourname/further/path' needs to be replaced with the correct path to the command, and needs to be single-quoted/escaped if it contains spaces or other unix-confounding characters -
Awkward shell script in Applescript
Hi,
I'm trying to get the following line of code to run in an Applescript:
ifconfig | grep "inet " | grep 192.168 | cut -d\ -f2
It works perfectly in terminal, but I can't for the life of me to work in an Applescript (I am aware of the double spacing requirements).
Any advice would be most welcomed.Is this what you want?
do shell script "ifconfig | awk '/inet/ { if (match($2, /192\.168\./)) print $2; }'" -
Shell Script or Applescript to run disk permissions repair
Tried doing this Applescript in Automator:
do shell script "sudo diskutil repairPermissions /" ¬
password "yourAdminPassword" with administrator privileges
This works, but the process appears to run without shutting down when it's done.
Can anybody suggest an addition or modification to terminate when the permissions repair is completed?do shell script ¬
"sudo diskutil repairPermissions / ; exit" password "yourpassword" with administrator privileges -
I can't get a simple "do shell script" in AppleScript to work!
Hi All,
I can get simple commands like "do shell script "ls"" or "do shell script "ps"" to work in AppleScript, but I cannot get something like "do shell script "python -V"" to work. (yes, my shell script says: do shell script "python -V" (no double quotes!))
This is driving me nuts!
Can anyone help?
- Jonpython -V appears to direct its output to stderr. Try
do shell script "python -V 2>&1" -
What's the syntax for Insert statement in Servlet?
I'm trying to insert record into table using servlet. Can you please show me the statement and syntax of how to use it?
hi
we can insert in 2 types
1) to all column insert
insert into <tablename> values ( 1,2,3,4...n);
2) particular column insert
insert into <tablename> ( col1,col2,col3...n) values ( value1 for col1, 2 , 3...n);
ex:
PreparedStatement ps = con.prepareStatement ( "insert into billtable (grandtotal,userid,creditno)values( ?,?,? )" );
//bill table
ps.setDouble ( 1, 10.50); //replace this double value with double variable
ps.setString ( 2, "vijay");
ps.setLong ( 3, 1111111111);
ps.executeUpdate ();
ps.clearParameters ();
ps.close ();More Details refer java with Jdbc concepts -
I want to insert like
insert into families(id, name) values(1,'Ram's car');
but due to 's in Ram's car error is occurring.
Plz suggest any solution.....Replace one single quote by two single quotes:
SQL> insert into families(id, name) values(1,'Ram''s
car');
1 row created.
SQL>
True, alternatively
insert into families(id, name) values(1,q'!Ram's car!');Both of which the OP would have easily discovered with a simple search. -
Hi All,
I have a large number of images that I need to resize the canvas sizes to a square, the images are currently in different sizes. For example, if an image is 1020 x 600 I would like to change the canvas to 1020 x 1020 so that the image becomes a square. I am using CS3 and all the images are jpeg's. I have done research on scripts but the ones I have tried have not worked. Please help.
Thanks.Since you do not want to crop your images to a square 1:1 aspect ratio changing the canvas to be square will not make your images square they will retain their Aspect Ratio and image size will be changer to fit within your 1020 px square. There will be a border or borders on a side or two borders on opposite sides. You do not need a script because Photoshop ships with a Plug-in script to be used in Actions. What is good about Plugins is the support Actions. When you record the action the plug-in during action recording records the setting you use in its dialog into the actions step. When the Action is played the Plug-in use the recorded setting an bypasses displaying its dialog. So the Action can be Batch. The Action you would record would have two Steps. Step 1 menu File>Automate>Fit Image... in the Fit Image dialog enter 1020 in the width and height fields. Step 2 Canvas size enter 1020 pixels in width and height not relative leave the anchor point centered it you want even borders on two sides set color to white in the canvas size dialog. You can batch the action.
The above script will also work. Its squares the document then re-sizes to 1020x1020 the action re-sizes the image to fit with in an area 1020 x 1020 then add any missing canvas. The script like the action only process one image so it would also need to be batched. Record the script into and action and batch the action. As the author wrote. The script re size canvas did not specify an anchor point so the default center anchor point is uses like the action canvas will be added to two sides.
Maybe you are looking for
-
Creating a virtual private network?
I've been reading some articles recently about creating a virtual private network for security and privacy reasons. Is it easy and is it a good thing to do? One part mentioned possibly having to pay a subscription for this service with your service p
-
Service item should not post to stock
Dear Experts, I have the following scenario. I have a service material (DIEN). And created a PO with Account assignment M with SO. I have done the GR, accounting entries are posted as: + KBS --> CoGS - WRX --> GR/IR Clearing Account entries are corre
-
How to install Oracle Database objects for BPA repository?
Hello, I have installed Oracle database (10.2.0.1) EE. I have run the following command to install BPA repository and site manager. ./install_bpr10.1.3.4.271679.sh -bpr_type BS_SM -jvm ./bpa10.1.3.4/jdk1.5.0/ -dbserver rstnxlin011.oracle.com -dbport
-
I want to buy NI cam for my machine vision system
Dear member I need to buy a NI cam to use it in my machine vision system that is used to in recognition of screws head like in second figure the problem is that my web cam is not able to produce high quality image so I need no but NI cam high quality
-
Bluetooth Keyboard K1280C not working on playbook
I bought a bluetooth keyboard on ebay: http://www.ebay.com/itm/220982485208?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_1851wt_13... It works on my PC, laptop and iphone, ipad. But not working on my lovely playbook it stucks at the pairing