Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:54 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Uploading files to your WEBmite

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 07:53am 13 Jul 2023
Copy link to clipboard 
Print this post

This assumes that you have already enabled TFTP on your Windows PC.
Create a batch file with the following contents.
echo %1
echo %~nx1
tftp -i 10.1.0.232 PUT %1 %~nx1

pause

Save it as a batch file where-ever you put this sort of thing and create a desktop shortcut.
On the WEBmite, change to the destination directory.

Start dragging files onto the shortcut, one at a time.
They upload at a pleasing, fast speed without the padding that XMODEM gives.

Once you are happy that it works, you can dispense with the ECHO lines and the PAUSE.

Linux users should be able to do similar with a shell script but I don't know how to remove the path from the filename in Linux.

Jim
VK7JH
MMedit   MMBasic Help
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3804
Posted: 08:41am 13 Jul 2023
Copy link to clipboard 
Print this post

What does echo %~nx1 do?

Need to understand it to convert to Linux :)

John
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 09:49am 13 Jul 2023
Copy link to clipboard 
Print this post

the %1 is the first parameter passed
adding ~nx removes the path leaving the filename with extension. Just what we need on the WEBmite end.

ECHO is just there so you can see the results while experimenting.

I assume you need a regex expression to do the same in Linux. Regex is not my best friend.
Typical output of the above batch file
  Quote  C:\Apps>echo C:\Users\Jim\Documents\myapps\maximite\apps\aatest.bas
C:\Users\Jim\Documents\myapps\maximite\apps\aatest.bas

C:\Apps>echo aatest.bas
aatest.bas

C:\Apps>tftp -i 10.1.0.232 PUT C:\Users\Jim\Documents\myapps\maximite\apps\aatest.bas aatest.bas
Transfer successful: 65 bytes in 1 second(s), 65 bytes/s

C:\Apps>pause
Press any key to continue . . .

Jim
VK7JH
MMedit   MMBasic Help
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3804
Posted: 10:19am 13 Jul 2023
Copy link to clipboard 
Print this post

Linux can use
basename path

to get the last part.

I don't have a webmite but likely something like
tftp 192.168.0.5 -c put "$1" `basename $1`

(if the put command even needs the destination name?)

John
Edited 2023-07-13 20:28 by JohnS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 09:18pm 13 Jul 2023
Copy link to clipboard 
Print this post

Thanks for the hint.

In my experiments with Linux, I found I needed the TFTP HPA version of TFTP to get it to play fairly in shell scripts.

Based on your suggestion, I would try

terminal -x tftp -m binary 192.168.0.5 -c put "%1" 'basename %1'


terminal needs to be changed to suit and I advise using binary mode so one script handles text as well as images etc.

I also strongly advise using filenames and paths without any spaces in them. Spaces make life "interesting"

Jim
VK7JH
MMedit   MMBasic Help
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3804
Posted: 09:44pm 13 Jul 2023
Copy link to clipboard 
Print this post

For Linux the argument needs to be $1 not %1 and the basename part uses back quotes so it's substituted by the result of the basename.

I don't know the terminal command (not on my system).

John
Edited 2023-07-14 07:45 by JohnS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 10:04pm 13 Jul 2023
Copy link to clipboard 
Print this post

Thanks for the explanation.
This should be better
terminal -x tftp -m binary 192.168.0.5 -c put "$1" `basename $1`


I had trouble getting tftp to run the command properly unless I opened a new terminal session.
On my Mint-Mate, the terminal is called mate-terminal
Other systems call it gnome-terminal
Some just use terminal
If you enter commands at the command prompt, you are in a terminal and there will be a way of opening a new terminal, running a command, then closing the terminal.

My Linux knowledge is sod-all so I expect that I am using the wrong terminology.


Edit:
Changing 'terminal' to 'mate-terminal' (and setting the correct IP) and this script works perfectly.


Jim
Edited 2023-07-14 17:47 by TassyJim
VK7JH
MMedit   MMBasic Help
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024