How to pass multiple variables from AppleScript to Shell Script?


This_

I use Automator to do the following:

  1. Ask the user to select a folder (as a service action)
  2. Ask the user to choose a name from a list (AppleScript choose from list ...)
  3. Pass the chosen folder and chosen name to shell-script

I understand how to pass the folder selected in step 1 to step 2. But I don't understand how to pass these two variables between steps 2 and 3 (I can only pass one). I try return {answer, input}at step 2. But the shell-script fails with an error -[__NSArrayM fileSystemRepresentation]: unrecognized selector sent to instance 0x600000654b80.

Wadian

For example, when passing an argument list to a shell script action

return {"/Applications", "com.apple.application-bundle"}
  • $@Represents a flattened list joined by spaces ->"/Applications com.apple.application-bundle"
  • $1represents the first parameter ->"/Applications"
  • $2represents the second parameter ->"com.apple.application-bundle"

    etc...

The shell script looks like

mdfind -onlyin $1 "kMDItemContentType == $2"

Note: Make sure to pass arguments as arguments , not to stdin in shell script actions .

Related


How to pass variables from shell script to .muttrc?

Amanda I want mutt( mutt-kz, actually - I'd love to migrate to, neomuttbut it's a bigger project) to get the SMTP password passso I don't have to store it in the config file in clear text, but I'm not sure how to correctly The password is passed to mine .muttr

How to pass variables from shell script to .muttrc?

Amanda I want mutt( mutt-kz, actually - I'd love to migrate to, neomuttbut it's a bigger project) to get the SMTP password passso I don't have to store it in the config file in clear text, but I'm not sure how to correctly The password is passed to mine .muttr

How to pass variables from shell script to mysql script

in Nakyo I have a bunch of mysql scripts that use name1 as the database name and populate that database with my data . However, I want to be able to choose the name of the database instead of always naming it name1 everywhere in my sql script . I already have

How to pass shell script variables to Expect script?

User 2932003 I want to pass the $SPACE variable into the Expect script and get the output and then again into the Shell script. #!/bin/bash -x SPACE=$(df -h | awk '{ print $5 }' | grep -v Use |sort -n |tail -1 | cut -d % -f1) #set user "root" #set

Pass variables from shell script configuration file

Data mastery: I am going to write a shell script to install various services dynamically. I don't know much about shell scripting or Unix shell in general, so I really need some help. Here is my shell file. #!/bin/bash # Ask the user for their name echo What i

Pass variables from Jython (wsadmin) to shell script

Joey Cotter I'm trying to pass values retrieved from WebSphere to a Jython script invoked using wsadmin.sh to a variable in my invoker shell script. The caller shell script (getValue.sh) will have: #!/bin/sh /opt/ibm/WebSphere/AppServerV70/bin/wsadmin.sh -lan

Pass environment variables to shell script from Fastlane

Lorenzo B. I'm running Fastlane (a continuous build tool for iOS) to execute a custom shell script for decrypting files. This is an order. sh "./decrypt.sh ENV['ENCRYPTION_P12']" I can't figure out a way to pass environment variables to this script. Apparentl

Pass variables from shell script configuration file

Data mastery: I am going to write a shell script to install various services dynamically. I don't know much about shell scripting or Unix shell in general, so I really need some help. Here is my shell file. #!/bin/bash # Ask the user for their name echo What i

Pass variables from Jython (wsadmin) to shell script

Joey Cotter I'm trying to pass values retrieved from WebSphere to a Jython script called using wsadmin.sh to a variable in my caller shell script. The caller shell script (getValue.sh) will have: #!/bin/sh /opt/ibm/WebSphere/AppServerV70/bin/wsadmin.sh -lang

Pass variables from Python script to tcl shell

wolf 123 I'm new to this forum, so I apologize for any mistakes. I am trying to pass variables from my python code to a tcl script. The way I do it is: import os import Tkinter from Tkinter import * def set_impairments(port,delay): port=int(port) del

Pass environment variables to shell script from Fastlane

Lorenzo B. I'm running Fastlane (a continuous build tool for iOS) to execute a custom shell script for decrypting files. This is an order. sh "./decrypt.sh ENV['ENCRYPTION_P12']" I can't figure out a way to pass environment variables to this script. Apparentl

Pass variables from Jython (wsadmin) to shell script

Joey Cotter I'm trying to pass values retrieved from WebSphere to a Jython script called using wsadmin.sh to a variable in my caller shell script. The caller shell script (getValue.sh) will have: #!/bin/sh /opt/ibm/WebSphere/AppServerV70/bin/wsadmin.sh -lang

Pass environment variables to shell script from Fastlane

Lorenzo B. I'm running Fastlane (a continuous build tool for iOS) to execute a custom shell script for decrypting files. This is an order. sh "./decrypt.sh ENV['ENCRYPTION_P12']" I can't figure out a way to pass environment variables to this script. Apparentl

Pass variables from Jython (wsadmin) to shell script

Joey Cotter I'm trying to pass values retrieved from WebSphere to a Jython script called using wsadmin.sh to a variable in my caller shell script. The caller shell script (getValue.sh) will have: #!/bin/sh /opt/ibm/WebSphere/AppServerV70/bin/wsadmin.sh -lang

Pass variables from Java to shell script

call back I am trying to run a shell script from Java code. Currently, I am supplying the data manually in the script, but I would like to be able to supply the variables from the Java code running the script. Here is the Java code and script: public static vo

Pass variables from shell script configuration file

Data mastery: I am going to write a shell script to install various services dynamically. I don't know much about shell scripting or Unix shell in general, so I really need some help. Here is my shell file. #!/bin/bash # Ask the user for their name echo What i

Pass variables from shell script configuration file

Data mastery: I am going to write a shell script to install various services dynamically. I don't know much about shell scripting or Unix shell in general, so I really need some help. Here is my shell file. #!/bin/bash # Ask the user for their name echo What i

Pass variables from Jython (wsadmin) to shell script

Joey Cotter I'm trying to pass values retrieved from WebSphere to a Jython script called using wsadmin.sh to a variable in my caller shell script. The caller shell script (getValue.sh) will have: #!/bin/sh /opt/ibm/WebSphere/AppServerV70/bin/wsadmin.sh -lang

Pass environment variables to shell script from Fastlane

Lorenzo B. I'm running Fastlane (a continuous build tool for iOS) to execute a custom shell script for decrypting files. This is an order. sh "./decrypt.sh ENV['ENCRYPTION_P12']" I can't figure out a way to pass environment variables to this script. Apparentl

Pass variables from Java to shell script

call back I am trying to run a shell script from Java code. Currently, I am supplying the data manually in the script, but I would like to be able to supply the variables from the Java code running the script. Here is the Java code and script: public static vo

Pass multiple Applescript variables to Ruby

Kragili I'm working on a Ruby script that needs some variables from Applescript. Now, I've managed to grab them one at a time, but it doesn't look elegant and can be slow. E.g: note = %x{ osascript <<APPLESCRIPT tell application "Evernote" if selec

Pass multiple Applescript variables to Ruby

Kragili I'm working on a Ruby script that needs some variables from Applescript. Now, I've managed to grab them one at a time, but it doesn't look elegant and can be slow. E.g: note = %x{ osascript <<APPLESCRIPT tell application "Evernote" if selec

How to pass multiple variables from VBS to batch script?

geojf3 I have the following .bat file for running a series of jobs: run a vbs script to calculate first few weeks dates for monday and saturday Run a series of commands using calculated dates to extract data from commercial financial applications Run a vbs scr

Shell script how to pass arguments with spaces in variables

silver glitter I'm making a script for synchronizing directories with rsync over ssh. I'm having trouble trying to define a custom port. Suppose a normal working script has the following syntax: #! /bin/sh rval=2222 port="ssh -p $rval" rsync --progress -av -

Shell script how to pass arguments with spaces in variables

silver glitter I'm making a script for synchronizing directories with rsync over ssh. I'm having trouble trying to define a custom port. Suppose a normal working script has the following syntax: #! /bin/sh rval=2222 port="ssh -p $rval" rsync --progress -av -

Shell script how to pass arguments with spaces in variables

silver glitter I'm making a script for synchronizing directories with rsync over ssh. I'm having trouble trying to define a custom port. Suppose a normal working script has the following syntax: #! /bin/sh rval=2222 port="ssh -p $rval" rsync --progress -av -

Shell script how to pass arguments with spaces in variables

silver glitter I'm making a script for synchronizing directories with rsync over ssh. I'm having trouble trying to define a custom port. Suppose a normal working script has the following syntax: #! /bin/sh rval=2222 port="ssh -p $rval" rsync --progress -av -