Jump to content

Shell command works fine in iterm but won't in a Run Script object.


Recommended Posts

Hi guys,

 

i'm experiencing a weird issue here.

 

I open iterm, type a basic open command and it works juste fine.

I use the terminal / shell tool in Alfred, it works just fine too.

I copy/paste this command in a Run script object in a workflow and nothing happens.

Because i can't see errors, i got no idea what's going on.

 

Any clue ? :/

 

 

Link to comment

Hi guys,

 

i'm experiencing a weird issue here.

 

I open iterm, type a basic open command and it works juste fine.

I use the terminal / shell tool in Alfred, it works just fine too.

I copy/paste this command in a Run script object in a workflow and nothing happens.

Because i can't see errors, i got no idea what's going on.

 

Any clue ? :/

 

The Run Script object doesn't import your profile, so you likely need an absolute path to the command you are trying to run.

 

What command are you trying to run?

Link to comment

The Run Script object doesn't import your profile, so you likely need an absolute path to the command you are trying to run.

 

What command are you trying to run?

 

A basic open :

open -a ~/Applications/Aurora.app 'path/to/folder'

The tricky thing is that that Run script runs fine on my personal MB but on my iMac, at work, nothing happens.

The main difference between the two configs is that i got admin rights on my personal, but not at work.

 

Could it explain things ?

Link to comment

Ok so Aurora is installed in "Users/myprofile/Applications/Aurora.app"

 

i tried in iterm

open -a /Users/myprofile/Applications/Aurora.app

it works but don't work anymore if i add the ~

 

Still won't work in Run script object with or without the ~

 

Just out of curiosity, i added an script with a "pwd" command and it gave me that output :

"/Users/myprofile/Dropbox/configs/Alfred2/Alfred.alfredpreferences/workflows/user.workflow.IDXXX"

 

I don't know if it actually makes sense or not, but i'm a little bit confused and lost :D
 

Link to comment

echo  ~/ gives me "/Users/myprofile/"

I don't get why nothing i tried so far doesn't work.

 

I tried "open -a Aurora", still nothing. :|

 

 

Hey man, can you provide us with a screenshot of the settings and such of your Run Script module, and possible the layout of the Workflow as well? That will help me better assess what's going on if I can see your config.

 

Thanks

Link to comment

Sure.

 

FYI, i ran some more tests.
Alfred does find Aurora. If i don't specify any arguments, the script opens Aurora. So It's not what i think it was.

I'm wondering if the {query} is really passed correctly though.

 

Anyway, here are the screenshots.

 

Here is my workflow:

workflow.png

Note that the output object "Post Notification" if for testing purpose only.

 

Then i have a first Script (don't know if it's useful or not for you) that translate a DOS path (the {query}) into a Unix path:

first_script.png

 

 

And finally the script that open (well, *should* open) the translated {query} into my browser Aurora:

second_script.png

 

Hope it helps. :)

Link to comment

Sure.

 

FYI, i ran some more tests.

Alfred does find Aurora. If i don't specify any arguments, the script opens Aurora. So It's not what i think it was.

I'm wondering if the {query} is really passed correctly though.

 

Anyway, here are the screenshots.

 

Here is my workflow:

workflow.png

Note that the output object "Post Notification" if for testing purpose only.

 

Then i have a first Script (don't know if it's useful or not for you) that translate a DOS path (the {query}) into a Unix path:

first_script.png

 

 

And finally the script that open (well, *should* open) the translated {query} into my browser Aurora:

second_script.png

 

Hope it helps. :)

 

This seems fairly straight-forward. Assuming you pass a path into the workflow via the keyword? Stupid question but does the path passed to it happen to have a ' in the path? Tried wrapping the {query} in double quotes instead?

Link to comment

Yes, i pass the path via the keyword.

 

Actually, your question is not that stupid! :P

I can't tell you right now, not until Thursday (tomorrow's day off), but i'll definitely keep you posted.

Thanks.

Link to comment

This seems fairly straight-forward. Assuming you pass a path into the workflow via the keyword? Stupid question but does the path passed to it happen to have a ' in the path? Tried wrapping the {query} in double quotes instead?

 

So… i've been investigating. Tried many things to spot the filthy glitch.

I finally realised that the output has an extra carriage return,  just before the closing quote i guess, which could explain why my command open with firefox doesn't work.

 

To be sure i made a test by adding another notification output :

test_workflow.png

Nb: In the first script i just put an "echo "foobar""

 

The first notification has a {query} in the input Text.

The second has "foobar" in the input Text.

 

And this is what i got: 

notifications.png

 

You can see that the first one has an extra space.

Do you think it's a bug and if so, i should post it in the bug section of this forum, right ?

Link to comment

OK, got it.

Don't know why but it seems that, after my sed, my {query} had a trailing newline.

 

I added "tr -d '\n' at the end because having "echo -n '{query}'" didn't change anything, so now we're done.

 

Finally works like i wanted :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...