Running Filemaker 13 on Mac OSX Yosemite.
We have a quicklook script that has, up until Yosemite, worked without issue. Normally, it takes a .doc/.docx file in the container field and opens it up in Quicklook.
However in Yosemite, it opens qlmanage, then causes Filemaker to freeze and crash.
Set Variable [ $file ; Value: ${database}::Container Field ]
Set Variable [ $path ; Value: Get ( Temporary Path ) & $file ]
Set Variable [ $script ; Value:
Let (
thepath = Middle( $path ; Position ($path ; "/" ; 1 ; 2 ); Length ($path) ;
"set p to POSIX path of " & Quote (thepath) &
"¶ do shell script \"qlmanage -p \" & quoted form of p" )
]
Export Field Contents [Database::Container Field ; "$path" ]
Perform Applescript [ $script ]
Can anyone give me some ideas on what might be going wrong here?
Thanks
I succeeded with an edited version of your script using FileMaker Pro Advanced 14.0.2 running under OS X Yosemite 10.10.5 in a demo file that looked like this:
Set Variable [ $_file ; Value: GetAsText ( Table::container ) ]
Set Variable [ $_fm_path ; Value: Get ( TemporaryPath ) & $_file ]
Set Variable [ $_as_path ; Value: Middle (
$_fm_path;
Position ( $_fm_path; "/" ; 1 ; 2 ) ;
Length ( $_fm_path) )
]
Set Variable [ $_script ; Value: List (
"set p to POSIX path of " & Quote ( $_as_path ) ;
"do shell script \"qlmanage -p \" & quoted form of p" )
]
Export Field Contents [ Table::container ; “$_fm_path” ]
Perform AppleScript [ $_script ]
Exit Script []
The primary differences between this and what you showed are:
I used a direct reference to the table name. I'm actually not sure what ${database} refers to. Perhaps Get ( FileName )?
I stored the AppleScript path in a variable for easier debugging.
If this doesn't work, I'd work with the recommendation I gave about testing the execution of the contents of $_script in Script Editor and the contents of the shell's p variable in Terminal.
Related
Basically, I have this if statement that doing all required stuff
if [ -z "${x}" ]; then
echo "You must set x variable, please see readme.md on how to get & set this variable."
exit 1
fi
But I found a more cool solution:
echo "${x:?You must set x variable, please see readme.md on how to get & set this variable.}
It also works, but it has one major problem, if variable exist it print it to the cmd, is it possible to somehow show only error and if variable exist not to show it content?
Is it possible to pass 2 variables in that 1 function?
Something like that:
echo "${x,y:?You must set x,y variable, please see readme.md on how to get & set this variable.}
You can use a no-op (:):
: ${x:?x is empty or not set} ${y:?y is empty or not set}
Or
: ${x?x is not set} ${y?y is not set}
Be aware of the difference between empty and not set.
You can also test if a variable is set or not:
[[ -v x ]] || { echo x is not set >&2; exit 1; }
I do use the no-op thing sometimes, but usually I make a die function for errors:
die()
{
echo "$#" >&2
exit 1
}
[[ -v x ]] || die x is not set
edit: I was wrong to say you need a test to check if a variable is set or not. I couldn't remember the syntax and missed it in the documentation.
Like other expansion logic, you can omit the colon (:) to change the check from if empty to if not set. So ${x?} causes an error if x is not set (and no error if set and empty), ${x:?} causes an error if x is not set, or set but empty.
I modified the answer accordingly.
My requirement is to delete file based on it displayed. Following is code snippet where I listed files but when I select option it displays file and when I capture file name its not happening only getting key not VALUE($REPLY only displays key but not value). Can someone help me out.
#!/bin/bash
select list in $(ls *.tmp)
do
echo $list
echo Do you want to delete files ?
read userInput
echo "UserInput is :: " $userInput
echo "Reply is :: " $REPLY
if [ $userInput == $REPLY ] ; then
# rm $REPLY
echo 'Yes'
break
done
----OUTPUT-----
1) +~JF1905393034413613060.tmp
2) +~JF2032005334435574091.tmp
3) +~JF3116454937363220082.tmp
4) +~JF3334986634800781310.tmp
5) +~JF3651229840772890748.tmp
6) +~JF3882306323060007639.tmp
7) +~JF573641658479505435.tmp
8) +~JF6137053351660236007.tmp
9) +~JF6277682393160684532.tmp
10) +~JF6385610668752278364.tmp
11) +~JF6824954027739238354.tmp
12) +~JF7876557427734797684.tmp
#? 4
+~JF3334986634800781310.tmp
Do you want to delete files ?
y
UserInput is :: y
Reply is :: 4
No
Try this:
PS3="Pick a file number to delete (or Ctrl-C to quit): "
select f in *.tmp ; do echo rm "$f" ; done
Then remove the echo to make it actually delete files.
i am experiencing a Problem with the printf function on MAC OS X terminal.
I already declared a variable and when i call it, it works. The problem is the following:
On the text i have some variables that start with "$" but belong to another system. I just want them to be printed on the file i am creating exactly this way ($foo) without bash trying to read them as its own variables. The result i get is an empty string.
I have the following code (dummy code):
echo "Type the wished folder name followed by [ENTER]:"
read baseName
echo '' > ext_emconf.php
printf " $VARIABLE[$ANOTHERVARIABLE] = [
'title' => '%s - Templates'
];
" $basename> ext_emconf.php
The result i get is this after the user gave for example "Amazon":
[] = [
'title' => 'Amazon - Templates'
];
Although i was expecting:
$VARIABLE[$ANOTHERVARIABLE] = [
'title' => 'Amazon - Templates'
];
Thanks in advance
It is double-quotes in bash tries to expand them as variables, but it has no definition for it. Use single quotes or better use here strings to print nice multi line formatted strings. Here is a sample way to do with some variables.
foo=bar
bar=foo
basename=foobar
tee ext_emconf.php <<EOF
$foo[$bar] = [
'title' => '$basename- Templates'
];
EOF
The above example uses tee to write both to stdout and to the file mentioned. Also you can also just redirect stdout to /dev/null if you don't want it to be seen in console.
tee ext_emconf.php <<EOF > /dev/null
$foo[$bar] = [
'title' => '$basename- Templates'
];
EOF
I want all variables names are set in shell script. I have a file which contains key value pairs and I was read content from that file and store/set into variables. I want to do some processes if a variable is available/set otherwise I don't need to do those processes. How to achieve this.
For example I run loop in shell scripts in each iteration it gives one of the variables is set before that command.
If code like this
a=test1
b=test2
c=test3
for i in ???
do
echo $i
done
then I want output like this
a
b
c
What command is used o achieve this.
You could use set before and after setting the variables
e.g:
$ set > aux1
$ c=345
$ set > aux2
$ diff aux1 aux2
57c57
< PIPESTATUS=([0]="141" [1]="0")
---
> PIPESTATUS=([0]="0")
112a113
> c=345
If you have a pre-defined list of such variables, then you can test it like this:
for i in $(echo "a b c"); do
echo $i
done
If i could help you :
#!/bin/sh
# Define list of tests
LIST_TESTS=`cat list_test.txt`
for TEST in ${LIST_TESTS}
do
vartest=`echo ${TEST}`
if [ "${vartest}" = "" ]
# No Test
then
echo "*** WARNING*** Test not found"
else
echo "${vartest} is available"
fi
done
# Second Define list of tests
tabTest=('test1' 'test2' 'test3')
i=0
while [ "${tabTest[$i]}" != "" ]
do
echo "${tabTest[$i]} is available"
i=$(($i+1))
done
I have something like the following code
"file.txt" utf8 <file-reader> [ [ print ] each-line ] with-input-stream* ;
This works nicely for the current contents of file.txt and the processing (like printing in this case) ends when the end-of-file is reached. But I want the process to wait for new contents appended to the file and also process this. Or in other words, the current version implements Unix cat, but I want it to do tail -f.
I hoped with-input-stream* (mind the asterisk) would do the trick, as the docs say the stream is not closed at the end. But there must be something else I'm missing.
You're in luck, I wrote a utility like that a while ago. See https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Filesystem#tailing-a-file
USING: accessors io io.encodings.utf8 io.files io.monitors kernel namespaces ;
IN: examples.files.tail
: emit-changes ( monitor -- )
dup next-change drop
input-stream get output-stream get stream-copy* flush
emit-changes ;
: seek-input-end ( -- )
0 seek-end input-stream get stream>> stream-seek ;
: tail-file ( fname -- )
[
dup f <monitor> swap utf8 [
seek-input-end emit-changes
] with-file-reader
] with-monitors ;
Your problem I think is that the quotation given to with-input-stream* will implicitly close the stream (each-line does it). I don't know if that is a bug or not. A word like this can be used to read the full stream without closing it:
: my-stream-contents* ( stream -- seq )
[ [ stream-read1 dup ] curry [ ] ] [ stream-exemplar produce-as nip ] bi ;
Then:
IN: scratchpad "/tmp/foo" utf8 <file-reader> [ my-stream-contents* print ] keep
file contents here
...
--- Data stack:
T{ decoder f ~input-port~ utf8 f }
IN: scratchpad my-stream-contents* print
more file contents here
...