Slashes in Scripts parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-10-2015 12:53 PM
I am trying to pass a string with the character '/' in it
JSS seems to be removing that and everything after it when saving the parameter.
Is there an escape key I need to include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-10-2015 12:55 PM
Have you tried including a back slash before the forward slash / like this / ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-10-2015 12:56 PM
have you tried '/'? that is a in front of the /
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-10-2015 01:13 PM
To explain the suggestion, the backslash character escapes the next character. So say you want to do something with a file in /Library/Application Support. If you try doing
cp /Library/Application Support/file.example .
It will error out because no folder named Application exists in Library. To get around that, you add the "" in. So
cp /Library/Application Support/file.example .
will copy file.example to the current location. So for your needs, since you don't want the / to be treated as a file path, you'll need to add the backslash in front of it to escape the normal rules.
(You know what an escape key is, so this is less for you specifically and more for anyone down the line who stumbles here)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-11-2015 06:30 AM
I assume from how you worded your posting that you're talking about a script parameter, like $4 or whatever. If so, try wrapping the parameter or variable assigned to that parameter in the script in double quotes wherever you're using it in the script. For example.
#!/bin/sh
if [ ! -z "$4" ]; then
mystring="$4"
else
exit
fi
echo "$mystring"
$ sudo jamf runScript -script test.sh -path ~/Desktop/ -p1 "Hello/World"
$ Running script test.sh...
$ Script exit code: 0
$ Script result: Hello/World
I'm pretty sure that should conserve the slashes in the string since the quotes should stop it from being seen as path delimiters, and just instead as a string as you intended. My guess is its getting stripped off because the variable isn't quoted in your script, but hard to know since you didn't post the script itself.
