rejetto forum

scripts to make my life easier!

ubay25 · 8 · 7489

0 Members and 1 Guest are viewing this topic.

Offline ubay25

  • Occasional poster
  • *
    • Posts: 6
    • View Profile
Firstly, thank you for this brilliant software!

Now the problem, my tree structure is like this --> ROOT - MainFolder - UserFolder.
The "UserFolder" folder is a real folder named after a user account, so the user "John" has his folder named "John" (i.e. ROOT - MainFolder - John) which only he has access rights.
So I need to create about a hundred accounts with their own folders and permissions.

The script I can imagine will do this:
- %user% string (i.e. John)
- mkdir C:\MainFolder\%user%
- create account in HFS for %user%
- create %user% folder in HFS with the proper permissions for %user%

Any ideas or tips to get me started? Thanks you in advance!!!


Offline ubay25

  • Occasional poster
  • *
    • Posts: 6
    • View Profile
After a bit of searching on the forums I fond out about hfs.event and can use this code:

[every 2 seconds]
{.load|automatic.txt.}
{.delete|automatic.txt.}

The automatic.txt I came up with looks like this:

{.mkdir|C:\MainFolder\$name.}
{.mkdir|C:\MainFolder\$name\Public.}
{.add folder|real|C:\MainFolder\$name|/MainFolder/$name.}
{.add folder|real|C:\MainFolder\$name\Public|/MainFolder/$name/Public.}
{.new account|$name|password=password|enabled=true|member of=can change password.}
{.set item|/MainFolder/$name|hide=0|access=$name|delete=$name|upload=$name.}
{.set item|/MainFolder/$name/Public|hide=1|access=@anyone|delete=$name|upload=@anyone.}

2 Questions:
- Where or how do I define the $name variable?
- Are the commands on the script correct?


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
You need to create a script with those lines pasted 100x and then fill in the names manually.


Offline ubay25

  • Occasional poster
  • *
    • Posts: 6
    • View Profile
Are you serious? I hope you're joking.

Anyway, I managed to create a script (perl) that lets you (on the command line) define the $name variable and then outputs the commands to automatic.txt which then HFS executes on hfs.event.

One more question though, on the {.set item} command, how can I tell it to make the folder "Non Browseable"?

Many thanks!


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands#Virtual_File_System_manipulation

{.set item|x|browsable=0.}

Just an FYI, that wasn't implemented until the most recent beta build, so make sure you're not using an older version or it won't work.
« Last Edit: June 09, 2011, 06:47:40 PM by raybob95 »



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
1. you can LOOP on that code. You have {.for each.} {.for.} and {.while.} commands for that.
for each may be the best choice.

2. just for your information, the "automate" thing is solely to let an external app to ask HFS to run a script.
The quickest way to run some commands is to go in Debug > run script

3. i'm always happy when i see people scripting with HFS, despite its poor language.

4. to get the $name, that is a variable, you do
{.set|name|Frank.}
and then you retrieve it by {.^name.}
Consider this works inside a connection variable space.
If you need to work outside this context, in a system wide context (that i guess it's your case), you need to put a # symbol in front of the name of the variable, that is: #name
« Last Edit: June 10, 2011, 10:05:46 AM by rejetto »


Offline ubay25

  • Occasional poster
  • *
    • Posts: 6
    • View Profile
Quote
3. i'm always happy when i see people scripting with HFS, despite its poor language.

Thanks rejetto, I admire your humility!
I will work and try what you suggested so that I don't have to use an external app next time.

Anyway, I am attaching the perl script I made for other people who might be interested. You must have the code below in hfs.event:

Quote
[every 2 seconds]
{.load|automatic.txt.}
{.delete|automatic.txt.}

Script might be dirty, I'm not good at it!