Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: Platypus - Current Working Directory - write files

Posted on 2007-11-06 01:06:22 by youcontrol

Hi,

Trying to use Platypus to create an app out of a Perl script. Bu 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

# Create content
$content = "This is a test.";

# Save file
$name = "filename.txt";
$namestr = ">" . $name;
open NEWFILE, $namestr;
truncate NEWFILE, 1;
print NEWFILE "$content";
close NEWFILE;

I've tried wrapping the cd into a system call but did not get very far.
If you have anything you can point me at, I'd be very glad.

Wrapping this with Platypus does not produce any error messages but it
does not create the file (or I can't find it).

Thanks.

Markus

Report this message

#2: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-06 02:30:52 by kenslaterpa

On Nov 5, 7:06 pm, Markus S <youcont...@hispeed.ch> wrote:
> Hi,
>
> Trying to use Platypus to create an app out of a Perl script. Bu 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

Always include:
use strict;
use warnings;

These will help you in the long run even though you will be forced to
define all variables used.

>
> # Create content
> $content = "This is a test.";
>
> # Save file
> $name = "filename.txt";
> $namestr = ">" . $name;
> open NEWFILE, $namestr;

use the three argument form of open, use lexical filehandles and
handle the error condition.

open my $NEWFILE, '>', $name or die
"Unable to open $name for output: $!";

> truncate NEWFILE, 1;
> print NEWFILE "$content";
> close NEWFILE;
>
> I've tried wrapping the cd into a system call but did not get very far.
> If you have anything you can point me at, I'd be very glad.
>
> Wrapping this with Platypus does not produce any error messages but it
> does not create the file (or I can't find it).
>

I know nothing about Platypus, and you have no 'cd' in your code, so
I'm not certain I understand waht you are saying.

If you are saying you tried the system call in the Perl script, that
will not work as the system call creates a new process and the 'cd'
command will be executed in the new process. If you want to change a
directory in Perl use the 'chdir' function ('perldoc chdir' for
documentation).

> Thanks.
>
> Markus

HTH, Ken

Report this message

#3: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-06 03:13:52 by Tad McClellan

Markus S <youcontrol@hispeed.ch> wrote:

> Trying to use Platypus


What is Platypus?


> to create an app out of a Perl script. Bu I
> can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to
> work in a Perl script.


There is no attempt to change directories in your code.

What did you try already?


> print NEWFILE "$content";


perldoc -q vars

What’s wrong with always quoting "$vars"?

so,

print NEWFILE $content;


> I've tried wrapping the cd into a system call but did not get very far.
> If you have anything you can point me at, I'd be very glad.


perldoc -f chdir

perldoc -q change

I {changed directory, modified my environment} in a perl script. How
come the change disappeared when I exited the script? How do I get my
changes to be visible?


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Report this message

#4: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-06 05:02:53 by Larry

In article <472fafff@news1-rz-ap.ethz.ch>,
Markus S <youcontrol@hispeed.ch> wrote:

> Trying to use Platypus to create an app out of a Perl script. Bu 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:

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

Report this message

#5: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-06 07:40:52 by Ben Morrow

Quoth Larry <dontmewithme@got.it>:
> In article <472fafff@news1-rz-ap.ethz.ch>,
> Markus S <youcontrol@hispeed.ch> wrote:
>
> > Trying to use Platypus to create an app out of a Perl script. Bu 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:
>
> 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

If that works (I've no idea what Platypus is, so I can't comment on
that) then you can do it in Perl instead:

Script Type: Shell
Script Path: this perl script:

#!/usr/bin/perl

use strict;
use warnings;

# it's always worth being portable when it's easy...
use File::Spec::Functions;

my $Res = catdir $ARGV[0], qw/Contents Resources/;
chdir $Res or die "can't cd to '$Res': $!";

# carry on...

Ben

Report this message

#6: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-06 12:38:38 by Joe Smith

Tad McClellan wrote:

> What ⠀ ™ s wrong with always quoting "$vars"?

Tad,
The headers on your posting says

Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: slrn/0.9.8.1pl1 (Linux)

yet the article body has UTF-8 characters.

-Joe

Report this message

#7: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-06 13:25:52 by youcontrol

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.

(For all others, you can find out about Platypus here:
http://www.sveinbjorn.org/platypus)

Report this message

#8: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-07 01:34:43 by rvtol+news

Joe Smith schreef:
> Tad McClellan wrote:
>
>> What ⠀ ™ s wrong with always quoting "$vars"?
>
> Tad,
> The headers on your posting says
>
> Mime-Version: 1.0
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8bit
> User-Agent: slrn/0.9.8.1pl1 (Linux)
>
> yet the article body has UTF-8 characters.

Yes, Tad does that frequently. He could just use

LANG= perldoc -q vars

before copy/pasting, but he insists in forgetting that.

--
Affijn, Ruud

"Gewoon is een tijger."

Report this message

#9: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-07 03:12:15 by Tad McClellan

Dr.Ruud <rvtol+news@isolution.nl> wrote:
> Joe Smith schreef:
>> Tad McClellan wrote:
>>
>>> What ⠀ ™ s wrong with always quoting "$vars"?
>>
>> Tad,
>> The headers on your posting says
>>
>> Mime-Version: 1.0
>> Content-Type: text/plain; charset=iso-8859-1
>> Content-Transfer-Encoding: 8bit
>> User-Agent: slrn/0.9.8.1pl1 (Linux)
>>
>> yet the article body has UTF-8 characters.
>
> Yes, Tad does that frequently. He could just use
>
> LANG= perldoc -q vars
>
> before copy/pasting, but he insists in forgetting that.


Rather, I keep forgetting to

perldoc -uq vars

before copy/paste.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Report this message

#10: Re: Platypus - Current Working Directory - write files

Posted on 2007-11-10 23:24:06 by hjp-usenet2

On 2007-11-06 12:25, Markus S <youcontrol@hispeed.ch> wrote:
> 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.

Put double quotes around $1.

Or do the chdir inside the perl script.

hp

--
_ | Peter J. Holzer | It took a genius to create [TeX],
|_|_) | Sysadmin WSR | and it takes a genius to maintain it.
| | | hjp@hjp.at | That's not engineering, that's art.
__/ | http://www.hjp.at/ | -- David Kastrup in comp.text.tex

Report this message