I have attempted to create a workflow that search Pubmed.org for scientific articles. The idea is to enter a string into Alfred 2 separated by commas and have a bash script parse the output so that it is formatted for searching the website. I'm doing this by triggering input with a keyword and then running the script. The output is an Applescript calling Alfred 2 to search for a keyword pointing at a second part of the workflow which is an "open URL" action. The problem is that when calling Alfred 2 back, sometimes it emulates pressing enter and sometimes not leaving Alfred 2 open with the parsed search string. I must have done something wrong with the Applescript. Suggestions is most welcome!
Bash script for parsing
echo '{query}'| awk '{split($0,array,",")} END{print array[1]"[ta] " array[2]"[vi] " array[3]"[pg]"}'
If I write Science,2,34 the parsed output will be Science[ta] 2[vi] 34[pg]
With the following Applescript I call another part of the workflow with the keyword "pmweb", and as I mentioned earlier, the key code 36 is not always working. If I manually press "Enter", the search is performed.
tell application "Alfred 2" to search "pmweb {query}"
tell application "System Events"
key code 36
end tell