MarkMc

Ruby-safe level, directory

Recommended Posts

Working on this cabinet price thing again. Yesterday I set up to read a text file and got that to work. Opened plan this morning and get evaluation errors.

Which I don't' understand. Checked with Dir.pwd and to find that Ruby is using the windows/system32 directory. Since I'm going to be giving this off to some others I don't want to use that.

  1. I found that to change directory I have to change the Safe level to 1. Wondering if that is seriously risky to give to others?
  2. I first tested a macro that simply changed the directory-once I did that the File.read macro worked. (I'm guessing that since the change directory executed) Does that create other problems that I don't know about?
  3. I'm thinking of setting up a directory "C:\Users\CA" to place the files. At least on Windows that is the simplest for me to hand off to others to create themselves and write into the macro? Don't know about on a Mac?
  4. I'm assuming that I need to write in some form of escape for this, yes?

Share this post


Link to post
Share on other sites

It sounds like you may be over complicating things.  There should be no reason to change any directory.  Not sure what exactly you’re doing, but I can get Ruby to read any relevant file on my system with the safe level turned up to max.  

Share this post


Link to post
Share on other sites
41 minutes ago, Alaskan_Son said:

It sounds like you may be over complicating things.  There should be no reason to change any directory.  Not sure what exactly you’re doing, but I can get Ruby to read any relevant file on my system with the safe level turned up to max.  

I don't understand it. This worked fine last night, shut down computer, turned it on and get this. The only way I could get it back was to change directory which required changing safety level.

Error.png

Share this post


Link to post
Share on other sites
4 hours ago, MarkMc said:

I don't understand it. This worked fine last night, shut down computer, turned it on and get this. The only way I could get it back was to change directory which required changing safety level.

Error.png

 

You have to give Ruby the entire file path.

Share this post


Link to post
Share on other sites
58 minutes ago, Alaskan_Son said:

You have to give Ruby the entire file path.

Well sort of- a copy of the path with standard backslashes "C:\Users\Mark\Documents\Chief Architect Premier X10 Data\Scripts\mod_test.txt" produces an error

145925226_standardpath.thumb.png.09e5a00649f736a38d71858c1dfaeac5.png

OTOH, reversing the slashes works , with or without the drive specified if it is on C ("/Users/Mark/Documents/Chief Architect Premier X10 Data/Scripts/mod_test.txt") -on another drive need all but still have to reverse the slashes.

 

I don't understand what happened when I had several of these working last night-pcan only guess pilot error of some sort....pretty sure I saved before closing, maybe I didn't, maybe I changed the directory while messing around and the simpler form worked-maybe it was late. I'd prefer the short form which I've seen listed in lots of places just don't know how I got it working yesterday. Thanks though...

 

Still have those original questions about safety if you or anyone would care to comment.

Share this post


Link to post
Share on other sites

I always have Ruby set to Safe Level 1.  I don't think it's necessary for reading files - but it definitely is for writing files or creating directories.  I've been doing this for years without any problems.  It could be a problem if you get a macro from someone else who is unscrupulous but otherwise you can even set the Safe Level to "0"

Share this post


Link to post
Share on other sites
On 12/22/2018 at 5:53 PM, Joe_Carrick said:

It could be a problem if you get a macro from someone else who is unscrupulous

...or just careless.  Particularly if those macros are writing or overwriting files. 

Share this post


Link to post
Share on other sites
8 hours ago, Alaskan_Son said:

...or just careless.  Particularly if those macros are writing or overwriting files. 

True.  I in fact use the ability to write and even over-write files and folders to accomplish certain tasks. 

Since I know what I'm doing and I am not malicious it's actually beneficial - but it would be fairly easy to create a macro that could erase files and even entire directories.  That's why CA set the default to level 2 but it is in fact a handcuff.

  • Upvote 1

Share this post


Link to post
Share on other sites

I have been using Joe's macro's for many years now without any problems what -so-ever.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Member Statistics

    28314
    Total Members
    6254
    Most Online
    06PeterMorris62
    Newest Member
    06PeterMorris62
    Joined