FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
199 views 3 comments
by anonymous
Is it possible copy an archive into RUT955 from a PLC´s SD memory, lets say every 24 hours?

 PLC is attached to RUT´s LAN. and the archive is in a file named " /weblist" of that memroy card.

thanks
by anonymous
In case, PLC has a web-server, and allows access using browser, try "wget http://plc_ip/weblist" from RUT.

1 Answer

0 votes
by anonymous

Hi,

This will of course depend on your PLC, but assuming scp is available, you can try the following on RUT955. Connect to RUT955 via CLI/SSH and execute the following commands:

  • opkg update
  • opkg install sshpass

With this package, you will be able to pass your password via SCP command, which will be used to download the file.

Next, to download an archive, you can use the following command on RUT955 to download a file from PLC:

  • sshpass -p <PLC_ROOT_PASSWORD> scp <PLC_ROOT/USERNAME>@<PLC_IP_ADDRESS:<FILE_PATH_ON_PLC> <FILE_PATH_ON_RUT955>

For example,

  • sshpass -p admin01 scp root@192.168.1.10:/etc/test_archive /etc

This command will download the file test_archive from PLC to the '/etc' folder in RUT955. In this case, we have authorized via username 'root' and password 'admin01'. These should be your PLC credentials.

If you want to update the file every 24 hours, you can put this command into a script and execute it every 24 hours via crontab.

To create a script, use the following commands:

  • touch /etc/download_archive.sh
  • chmod +x /etc/download_archive.sh
  • vi /etc/download_archive.sh

You will open a text editor. Press 'i' to start editing. Paste the following (change according to your needs):

#!/bin/sh

sshpass -p admin01 scp root@192.168.1.10:/etc/test_archive /etc

Save the script by pressing  'esc' button, typing ':wq' and pressing 'enter'. The script should be created. 

To add these commands to crontab, execute the following command:

  • crontab -e

It will open in text editor. Press 'i' to start editing. To run the script everyday at midnight (every 24hours) add the following:

  • 0 0 * * * sh /etc/download_archive.sh >/dev/null 2>&1

Save your changes by pressing  'esc' button, typing ':wq' and pressing 'enter'.

This will execute the script and download the file every day at midnight.

You can change the times if you want. More information about crontab can be found here. You can also use crontab generator like the one here.

Kind Regards,

Andzej

by anonymous
Hi, thanks  we have the case PLC has a web browser, the issue is copy the archive to a expansion memory in RUT´s USB port, once per day and then send it via FTP
by anonymous

Hi,

To download a file to RUT via wget, you can use the following command:

  • sshpass -p <password> wget -P <path_where_to_save> <user>@<hostIP>/<path_to_file>

For example:

  • sshpass -p admin01 wget -P /etc root@192.168.1.1/etc/archive

To upload a file from RUT to another device via SFTP, you can use the following command:

  • sshpass -p <password> sftp <user>@<host>:<path_to_save> <<< $'put <path_to_file_to_send>'

For example:

  • sshpass -p admin01 sftp root@192.168.1.1:/etc <<< $'put ./mydocuments/archive'

You can add these commands to crontab to execute at specific times as described in my previous response.

Kind Regards,

Andzej