OS X - how to write to a file associated as a Unix executable

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

OS X - how to write to a file associated as a Unix executable

Glen Bojsza
Hello,

I am trying to write the from a text field to a file and then change the
file so it is executable.

put field "mytest" into URL "binfile:~/race"
or
put field "mytest" into URL "file:~/race"

The file race is created in either case but are associated with textedit.

I require it to be recognized as a Unix executable associated with the
terminal application once I have done a chmod +rx on it

If I just save a file from textmate and do a chmod +rx then it works.

So it has to do with how I am saving it out of LC.

Any suggestions?

thanks,

Glen
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Warren Samples
On 02/29/2016 03:13 PM, Glen Bojsza wrote:

> Hello,
>
> I am trying to write the from a text field to a file and then change the
> file so it is executable.
>
> put field "mytest" into URL "binfile:~/race"
> or
> put field "mytest" into URL"file:~/race"
>
> The file race is created in either case but are associated with textedit.
>
> I require it to be recognized as a Unix executable associated with the
> terminal application once I have done a chmod +rx on it
>
> If I just save a file from textmate and do a chmod +rx then it works.
>
> So it has to do with how I am saving it out of LC.
>
> Any suggestions?
>
> thanks,
>
> Glen


You could look into fileType in the dictionary. I can recall having to
explicitly set the file type for images saved from LiveCode or they
would open in an editor because LiveCode was saving them as text files.

You could also try using 'get shell()' and whatever command or method
you feel most appropriate given you content, to create the file and then
make it executable by

'get shell("chomd +x /your/new/file")'

This works here under Linux and <should> work under OS X because the
file itself is being created and saved by the system instead of by LiveCode.


Warren

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Warren Samples
On 02/29/2016 06:06 PM, Warren Samples wrote:
> 'get shell("chomd +x /your/new/file")'


Well, that of course won't work jaja.

chmod


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Glen Bojsza
In reply to this post by Warren Samples
This only works IF the file created is associated with the terminal
application.

The issue is creating the proper file format so when the chmod creates it
as Unix executable.

On Mon, Feb 29, 2016 at 7:06 PM, Warren Samples <[hidden email]>
wrote:

> On 02/29/2016 03:13 PM, Glen Bojsza wrote:
>
>> Hello,
>>
>> I am trying to write the from a text field to a file and then change the
>> file so it is executable.
>>
>> put field "mytest" into URL "binfile:~/race"
>> or
>> put field "mytest" into URL"file:~/race"
>>
>> The file race is created in either case but are associated with textedit.
>>
>> I require it to be recognized as a Unix executable associated with the
>> terminal application once I have done a chmod +rx on it
>>
>> If I just save a file from textmate and do a chmod +rx then it works.
>>
>> So it has to do with how I am saving it out of LC.
>>
>> Any suggestions?
>>
>> thanks,
>>
>> Glen
>>
>
>
> You could look into fileType in the dictionary. I can recall having to
> explicitly set the file type for images saved from LiveCode or they would
> open in an editor because LiveCode was saving them as text files.
>
> You could also try using 'get shell()' and whatever command or method you
> feel most appropriate given you content, to create the file and then make
> it executable by
>
> 'get shell("chomd +x /your/new/file")'
>
> This works here under Linux and <should> work under OS X because the file
> itself is being created and saved by the system instead of by LiveCode.
>
>
> Warren
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Warren Samples
On 02/29/2016 06:09 PM, Glen Bojsza wrote:
> This only works IF the file created is associated with the terminal
> application.
>
> The issue is creating the proper file format so when the chmod creates it
> as Unix executable.


Are you saying that saving a file from TextMate and chmoding it works
but using Terminal and 'print "something-that-will-execute" >
/output/file' or 'cat /working/file > /working/file-cloned' and chmoding
that file doesn't?

Warren


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Glen Bojsza
What I am trying to do is within a LC application

1. put field "mytest" into URL "binfile:~/race"

This creates a file called race in the ~/ directory.

The problem is that when you do a chmod +rw race the file is still
recognized as textedit file and NOT a UNIX executable.

When you look at a file created with LC and chmod  verses a file created
with textmate and chmod you can see the differences in the finder or get
info on both files and see the difference.


On Mon, Feb 29, 2016 at 7:52 PM, Warren Samples <[hidden email]>
wrote:

> On 02/29/2016 06:09 PM, Glen Bojsza wrote:
>
>> This only works IF the file created is associated with the terminal
>> application.
>>
>> The issue is creating the proper file format so when the chmod creates it
>> as Unix executable.
>>
>
>
> Are you saying that saving a file from TextMate and chmoding it works but
> using Terminal and 'print "something-that-will-execute" > /output/file' or
> 'cat /working/file > /working/file-cloned' and chmoding that file doesn't?
>
>
> Warren
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Warren Samples
On 02/29/2016 07:06 PM, Glen Bojsza wrote:

> What I am trying to do is within a LC application
>
> 1. put field "mytest" into URL "binfile:~/race"
>
> This creates a file called race in the ~/ directory.
>
> The problem is that when you do a chmod +rw race the file is still
> recognized as textedit file and NOT a UNIX executable.
>
> When you look at a file created with LC and chmod  verses a file created
> with textmate and chmod you can see the differences in the finder or get
> info on both files and see the difference.


I understand the problem. What I am asking you is if creating a file
using the shell function in LC instead of saving it directly from LC
works. I can't tell from your response if you have tried it.
The first step would be to get the path of a file you know does what you
want it to do. Then open a terminal and type:

cat /file-that-works > /file-that-works-new

then:

chmod +rx /file-that-works-new

Does this file do what you hope? If it does then the next step is to do
the same thing using LiveCode's shell function. This should give the
same result as using a terminal.

get shell("cat /file-that-works > /file-that-works3")
get shell("chmod +rx /file-that-works3")

We are attempting to bypass LiveCode's unfortunate desire to save
everything as a text file and create a hard association with TextEdit in
OS X.

I'm a little curious also about how you are telling TextMate to create
and/or save the file. Are you explicitly telling it to create a shell
script?


Warren

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Mark Waddingham-2
In reply to this post by Glen Bojsza
On 2016-03-01 02:06, Glen Bojsza wrote:

> What I am trying to do is within a LC application
>
> 1. put field "mytest" into URL "binfile:~/race"
>
> This creates a file called race in the ~/ directory.
>
> The problem is that when you do a chmod +rw race the file is still
> recognized as textedit file and NOT a UNIX executable.
>
> When you look at a file created with LC and chmod  verses a file
> created
> with textmate and chmod you can see the differences in the finder or
> get
> info on both files and see the difference.

Try doing:

set the fileType to "????????"

or

set the fileType to empty

Before saving the file from LC.

The default setting is "ttxtTEXT". I believe, these days, that Mac first
looks at the file extension and then falls back to the filetype. As the
engine is explicitly setting the fileType of saved files (by default) to
text, the OS will pick up any files without extensions as text files.

Warmest Regards,

Mark.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: OS X - how to write to a file associated as a Unix executable

Glen Bojsza
Thanks Mark

That did it ... both methods of filetype allowed me to correctly get the
chmod results I was looking for.



On Tue, Mar 1, 2016 at 2:54 AM, Mark Waddingham <[hidden email]> wrote:

> On 2016-03-01 02:06, Glen Bojsza wrote:
>
>> What I am trying to do is within a LC application
>>
>> 1. put field "mytest" into URL "binfile:~/race"
>>
>> This creates a file called race in the ~/ directory.
>>
>> The problem is that when you do a chmod +rw race the file is still
>> recognized as textedit file and NOT a UNIX executable.
>>
>> When you look at a file created with LC and chmod  verses a file created
>> with textmate and chmod you can see the differences in the finder or get
>> info on both files and see the difference.
>>
>
> Try doing:
>
> set the fileType to "????????"
>
> or
>
> set the fileType to empty
>
> Before saving the file from LC.
>
> The default setting is "ttxtTEXT". I believe, these days, that Mac first
> looks at the file extension and then falls back to the filetype. As the
> engine is explicitly setting the fileType of saved files (by default) to
> text, the OS will pick up any files without extensions as text files.
>
> Warmest Regards,
>
> Mark.
>
> --
> Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode