Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have to send files to a remote drive (15 miles away) every now and then.
I send them one at a time. Each one takes up to an hour.
So I wanted to automate it using Zenity.
The idea was to send one file, wait, say 30 minutes, and send the next till the directory was empty.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Rep:
What exactly is the object here? You want a progress bar for the transfers? I can't get a grasp on what's going on. How are the two drives connected, Internet? You can get a progress bar with rsync, using pv or the --progress switch. I've never used zenity for file transfer applications.
Perhaps if you give more surrounding context about the situation. Do you just like gui dialogs? How is it you're able to use the mv command on a drive 15 miles away. Do you have a tunnel? I'm just missing a lot here.
If I put a file into the Synology Cloudstation directory, it is transferred by the Synology Sync app to the Synology NAS 15 miles away.
That's it.
So as far as Zenity is concerned, it is a simple case of transferring files, one at a time, from one directory in my computer to another directory in my computer.
At the moment, I test it just with directory fred and directory joe, with about 6 small text files, and a delay of 1 minute. That's how I know it doesn't work.
I just wanted to do it on its own, without me, and with some visual progress on how long it is till the next file transfer..
The original one (below) does, but it has no meaningful progress, just a bored Cylon.
I have to send files to a remote drive (15 miles away) every now and then.
I send them one at a time. Each one takes up to an hour. So I wanted to automate it using Zenity
...
now theres your problem, zenity isnt used for automation. its used for creating gui dialogs for the user to manually interact with.
does synology cloudstation provide any normal interfaces like ssh/scp, nfs ?
I send these files one at a time to a drive that has no high speed fibre.
The Synology sync can only handle one file at a time, as because there is no high speed line, the file takes about an hour to send. More than 1 file at a time, and Synology can't handle it.
I send at night. I just want to see the bar creep up, so I know it's working, leave it on and go to bed.
I do not own the drive.
The Linux Synology app is extremely basic, and I can give no details on it.
Is this not just a problem with syntax?
Going deep into the reason why isn't helping.
Perhaps you should let this post die, and I'll unsubscribe.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Rep:
I see your dilemma. You'd like to use a GUI window to run the 'mv' command, and you want a progress bar to check progress of the file transfer. Zenity won't do that. It will show the progress of a number of tasks, but only how you tell it to. See this: https://ubuntuforums.org/showthread.php?t=2172828
If you use rsync --progress to transfer the files, it will actually tell you the progress of the transfer. I'm still a bit in the dark in that you say you can only transfer one file at a time. All file transfer programs do that. They don't transfer more than one file simultaneously.
Not really, I wanted the mv command to move files one at a time, and use the sleep command between each transfer, piped to Zenity.
Below was another method used.
I can do the move command one at a time,
In another attempt:
I used :
Code:
for i in {1..100..1}; do echo $i; sleep "$pc"; done | zenity --progress --percentage=0 --auto-close
with pc set to 1, and it works great alone.
And using a different idea, I fitted it into:
Code:
#!/usr/bin/env bash
cd ~/Downloads
d1="$(zenity --file-selection --title="Bulk Move Choose starting directory" --directory)"
d2="$(zenity --file-selection --title="Bulk Move Choose destination directory" --directory)"
delay="$(zenity --entry --title="Bulk Move" --text="Enter delay in minutes:")"
seconds=`echo "$delay *60" | bc`
pc=`echo "$seconds/100"| bc`
## Find all files and folders in the current directory, sort
## them reverse alphabetically and iterate through them
find "$d1" -maxdepth 1 -type f | sort -r | while IFS= read -r file; do
## Set the counter back to 0 for each file
counter=0;
## The counter will be 0 until the file is moved
while [ $counter -eq 0 ]; do
## Move the current file to $target and increment
## the counter.
mv -v "$file" "$d2" && counter=1;
for i in {1..100..1}; do echo $i; sleep "$pc"; done | zenity --progress --percentage=0 --auto-close
done;
done
But the for next sleep command flashes through, and each file transfers every second.
if it takes 1 hour to move 1 file why are you sleeping it for 30 minutes between each transfer? My brain wonders. When they will be moved in series one after the other. why are you waiting 30 minutes between each file? I'd think an hour each is long enough.
The math behind it would be start size of file, get rate of transfer, and do an approximate of time it takes until it reaches zero. then have it spit out the results every x seconds, or minutes to update you. or have it get total size at start, rate of transfer then update the stats of the amount transferred.
rate of transfer, amount transferred - total size = time it will finish. something like that, as far as looking at a bar in lue of numbers to tell you what is going on. that is out of my area of off the top of my head information.
I'd think if you're hooking up on a given static IP then use the network tools to get rate of transfer (ROT) to watch that IP / Port to get ROT, then do the math on each file max size - (M)bits transferred = time left.
Again, you're trying to read too much into this.
If they are smaller files, I would set the delay around 30 minutes.
If they are larger ones, up to an hour.
During the daytime, the transfer rate is around 30k per second.
At night the rate is 400 - 500 Kb per second.
I have no control over this. British Telecom just haven't got around to that village yet with fibre.
#!/usr/bin/env bash
#
cd ~/Downloads
d1="$(zenity --file-selection --title="Bulk Move Choose starting directory" --directory)"
d2="$(zenity --file-selection --title="Bulk Move Choose destination directory" --directory)"
delay="$(zenity --entry --title="Bulk Move" --text="Enter delay in minutes:")"
seconds=`echo "$delay *60" | bc`
count=1
if [ $seconds -le 100 ]; then
pc=1
else
pc=`echo "$seconds/100"| bc`
fi
## Find all files and folders in the current directory, sort
## them and iterate through them
find "$d1" -maxdepth 1 -type f | sort -n | while IFS= read file; do
## Set the flag back to 0 for each file
flag=0;
## The flag will be 0 until the file is moved
while [ $flag -eq 0 ]; do
## Move the current file to $d2 and increment the counter.
mv -v "$file" "$d2" && flag=1;
if [ -z "$(ls -A "$d1")" ]; then
zenity --info --text "Move Completed"
else
while [ $count -le 100 ]; do
count=$(( $count + 1 )); echo "$count"; sleep "$pc"; done | zenity --progress --text ${file##*/} --percentage=0 --auto-close --auto-kill;
fi
done;
done
I just want to see the bar creep up, so I know it's working
there is a cp and mv rewrite with progress bars, package is called advcp, and there is a python wrapper around cp and mv, package pycp.
both are not graphical, they display a progress bar in your terminal.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.