Add sub-directory to /unsecured

Is it possible to add a sub-directory to the EPIC /unsecured folder? I’m guessing I’ll have to get shell access and add it that way but i want to see if it would be visible from the groove Manager files page. And if write access would be an issue, save a file from PAC control.

Yes, it is possible.
Yes, you need to it via shell.
No, write issues are not a problem for PAC Control because when you are in shell making the sub-directory you will set the correct permissions (users) for that directory.

From shell;

mkdir /home/dev/unsecured/subdir
sudo chown pac22:unsecured_files /home/dev/unsecured/subdir/

Once that is done, set your file comm handle to that path in PAC Control;

When you write the file, it will show up in groov Manage just as usual;

Note the new path with the sub-directory in it.

2 Likes

I wonder if it would be possible to create a directory through PAC Control using the ftp commands? That way everything can be inside the strategy.

1 Like

So for a follow up,

I think Philip is talking about using Send Communication Handle Command through an ftp comm handle to localhost. “ftp:localhost:…”

Would you be able to send ftp commands to localhost without the SSH Server running on the EPIC? In other words, the SSH Server is the local ftp server correct? Without it running you can only use client side ftp functionality to some remote server?

I’m trying to come up with ways to get some basic file browser functionality between PAC control and the /unsecured folder on the EPIC, displayed in groov VIEW. Something like a list of files that the user can see then manually type in the file name they want to edit, load, replace, etc…

So I’m thinking with the local ftp server I can send ftp command dir to get file lists for display.

No FTP commands will not work because there is no FTP server listening on EPIC.
We decided that from the outset EPIC would not have any FTP functionally, it’s just too insecure.

The manual states that it should be possible to create any directory paths needed when you write the file (either with the a or w command), but I am not finding that in my testing (on 2.0 firmware).

Yes I was finding the same trouble. Initially I was trying to write a “file:a,~/unsecured/subdir/file.txt” and it would just throw an error instead of creating the subdir.

Ah, that’s helpful to know… and you would be on 1.5 firmware???
Do you recall if the error was -52?

According to this:

File write commands will not create subfolders. @Beno - any updates on that ticket?

As we say in Australia… yeah, nah.

Yeah, the ticket exists.
Nah, no progress on it.
Bleh. Let me tickle it and see what we get.

In the mean time, @e.schultz do you have a shell license?

Yes I’m on 1.5 and the error is -407 when OpenOutgoingCommunication is run and -52 when TransmitString is run. All for a comm handle as described above (“file:a,~/unsecured/subdir/file.txt”) where subdir does not exist.

And yes I just got the shell license uploaded.

Quick addition, to be able to write to the new subdir over sftp (using filezilla in my case)
I needed to change the file permissions.

So the complete set of commands for me was:

mkdir /home/dev/unsecured/subdir
sudo chown pac22:unsecured_files /home/dev/unsecured/subdir/
sudo chmod 775 /home/dev/unsecured/subdir/

Trying to change the permissions in filezilla was not allowed because of ‘permission denied’ – I needed sudo.

Correct.
Keep in mind that the PAC Control engine has different permissions/ is a different user than your Filezilla user.

I’m replying to this thread, as its something we may find useful. Attached is a photo of the ‘Files’ screen in ‘groovManage’. I’ve created two folders (subdirectories) in the \Unsecured area of the EPIC using Putty via Shell access. I used the ‘mkdir’ & ‘chmod’ commands. I used the ‘chown’ command for the \Data folder since this is the location that we would be writing (saving) files from the Opto Strategy. My question is: why do I not see these NEW folders in the \Unsecured path, but only in the ‘Dir Listing’ area? I’ve power cycled after the additions to the \Unsecured area. I can somewhat understand the \Data folder not showing up due to the ‘chown pac22…’ command, but the \Falex folder did not use the ‘chown’ command. I can’f locate any instructions in the EPIC Users Guide.
Thanks for the advice
Dave

I may be confused but do you mean the ‘Path’ as shown in your photo or are you having trouble accessing these folders in putty? alternatively can you see them in the address bar when you click on ‘Data’ or ‘Falex’?

I guess I thought once I added them to the \unsecured area in EPIC, I would see them added to the ‘Path’ window as in the example shown in this post. We will be writing (saving) files to the \Data folder from Strategy, but we may be writing (saving) files into the \Falex folder. The ‘Upload File’ button only allows me to ‘upload’ files into the \unsecured area and not the newly added folders. Does this help explain it a little better?
Dave

Okay, I get the process a little better. I inserted a USB into the EPIC, I could then see the contents of the USB. If I select a file from the USB and select it be copied, go back to the ‘Files’ area and select the newly added folder, the ‘Path’ changes to that folder in the \Unsecured area. It does work, its just a bit confusing. I don’t see this explained anywhere
Dave

That seems odd, I may have trouble picturing it. I think you’re on the right path.

When you click on a folder name under ‘Dir Listing’ it should open the desired folder, then selecting ‘Upload File’ should upload a file to the currently selected folder. As far as i know chown pac22 should not affect any of these steps.

I got it working yesterday, just trying to document it. As this will be implemented in many new units once we finish development of the new unit. If I don’t document it, in several months, I will forget the process.
My comment was that, besides these great forums, I did not find any Opto documentation/video explaining this process. I’m sure there are other users who is doing something similar.
Thanks for your tips
Dave

Sub-directories can be created fairly easily with Node-Red. Here are a couple examples, I made these on a RIO so they are in the /secured folder.

 [
     {
         "id": "f725ca04.50fb98",
         "type": "file",
         "z": "8975d3b4.47212",
         "name": "",
         "filename": "/home/dev/secured/subdir/filename.csv",
         "appendNewline": true,
         "createDir": true,
         "overwriteFile": "true",
         "encoding": "none",
         "x": 450,
         "y": 800,
         "wires": [
             []
         ]
     },
     {
         "id": "53a0d9e8.787398",
         "type": "function",
         "z": "8975d3b4.47212",
         "name": "Write file name and contents",
         "func": "var flowrate = 5;\nvar speed = 200;\nvar gain = -2;\nvar elapsed = 300;\nvar weight = 4500;\nmsg.payload=flowrate+\",\"+speed+\",\"+gain+\",\"+elapsed+\",\"+weight;\n\nvar home = \"home\";\nvar dev = \"dev\";\nvar secured = \"secured\";\nvar subdir2 = \"subdir2\";\nvar subsubdir2 = \"subsubdir2\";\n\nfile = \"/\"+ home + \"/\" + dev + \"/\" + secured + \"/\" + subdir2 + \"/\" + subsubdir2 + \".csv\";\nmsg.filename=file;\nreturn msg;",
         "outputs": 1,
         "noerr": 0,
         "x": 360,
         "y": 880,
         "wires": [
             [
                 "fe5fddea.eecde"
             ]
         ]
     },
     {
         "id": "fe5fddea.eecde",
         "type": "file",
         "z": "8975d3b4.47212",
         "name": "",
         "filename": "",
         "appendNewline": true,
         "createDir": true,
         "overwriteFile": "true",
         "encoding": "none",
         "x": 570,
         "y": 880,
         "wires": [
             []
         ]
     },
     {
         "id": "71ebf833.35a8f8",
         "type": "inject",
         "z": "8975d3b4.47212",
         "name": "",
         "topic": "",
         "payload": "",
         "payloadType": "str",
         "repeat": "",
         "crontab": "",
         "once": false,
         "onceDelay": 0.1,
         "x": 150,
         "y": 880,
         "wires": [
             [
                 "53a0d9e8.787398"
             ]
         ]
     },
     {
         "id": "2f8ffedc.e37e22",
         "type": "inject",
         "z": "8975d3b4.47212",
         "name": "",
         "topic": "",
         "payload": "Hello opto world",
         "payloadType": "str",
         "repeat": "",
         "crontab": "",
         "once": false,
         "onceDelay": 0.1,
         "x": 180,
         "y": 800,
         "wires": [
             [
                 "f725ca04.50fb98"
             ]
         ]
     },
     {
         "id": "2b56f4da.d515dc",
         "type": "comment",
         "z": "8975d3b4.47212",
         "name": "2 methods for creating subdirectories and files",
         "info": "",
         "x": 250,
         "y": 740,
         "wires": []
     }
 ]

Update and ‘closure’ on this thread / issue.

Its been fixed in groov EPIC firmware 2.0.2 or better.
Here is the KB; Opto22 - KB88831

The error returned varied for some depending on how the command was used, but generally -417 was the main error thrown. Long story short, you can now create sub-directories from within PAC Control. No more shell needed.