[platypus-dev] Platypus - Current Working Directory - write file
- From: "Lenny Roberts" <lenny.p.robert@xxxxxxxxx>
- To: platypus-dev@xxxxxxxxxxxxx
- Date: Tue, 6 Nov 2007 19:38:09 +0100
Hi,
Trying to use Platypus to create an app out of a Perl script. But I
can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to
work in a Perl script. My minimal Perl script would look this:
#! /usr/bin/perl
use strict;
use warnings;
# Create content
my $content = "This is a test.";
# Save file
my $name = "filename.txt";
open my $NEWFILE, '>', $name or die
"Unable to open $name for output: $!";
truncate $NEWFILE, 1;
print $NEWFILE $content;
close $NEWFILE;
Wrapping this with Platypus does not produce any error messages but it
does not create the file (or I can't find it).
I have posted this question on the Perl newsgroup and got this
suggestion by Larry:
> On 2007-11-06 5:02, Larry said:
>> > in Platypus window:
>> > Script Type: Shell
>> > Script Path: your start.sh
>> > the followin is the start.sh file:
>> > #!/bin/sh
>> > #
>> > # start.sh
>> > cd $1/Contents/Resources/
>> > /usr/bin/perl $1/Contents/Resources/my_perl_script.pl
> Thanks. Unfortunately, the $1 contains a space in my case and the cd
> command therefore fails. I would know how to deal with this within Perl
> but not on the Shell level.
Hi Larry,
Well, I've tried to run the whole thing on a path without spaces. There
it works, but I have to manually place the Perl script in
Contents/Resources after building the app. I also have tell it to write
the output file three directory levels higher. All doable but a bit
cumbersome. Biggest problem however, is that the app does no longer
seem to be droppable, or at least the 'drops' don't reach the Perl
script. I guess the Shell script would have to hand them over. Knowing
very little about about Shell scripts, I am at a loss here.
I've also tried to use sed to escape the spaces but am more less just
fumbling around:
p = "$1/Contents/Resources/";
q = $(echo $p | sed 's/ /\\ /g')
cd $q;
Other related posts:
- » [platypus-dev] Platypus - Current Working Directory - write file