LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-11-2013, 03:05 AM   #1
defila
LQ Newbie
 
Registered: Aug 2013
Posts: 14

Rep: Reputation: Disabled
How to "pipe" function into "echo"?


Hello,

Could you please help me to solve below issue? I have created pseudocode which will download files from ftp and will show the progress of the transfer.
The code below works but the issue is that it will show the progress of the bar at first and then it will download all files (...) Is it possible to pipe the "downld" function into the "echo" function somehow?
I did try several things but it failed or ended in the same result

Code:
cd $HOME/test/"$dir"
dwnld () {
ftp -in <<+
open $ftp $port
user $user $pwd
cd $fdir
mget *.txt
bye
+
}
count=$(
ftp -in <<+
open $ftp $port
user $user $pwd
cd $fdir
ls
bye
+
)
result=$(echo "$count" | grep -v "user|ls|^d|bye" | wc -l)
for (( i=0; i<=$result; i++ ))
do
	echo "$(( (i * 100) /$result ))"
	dwnld
	sleep 0.1
done |  zenity --progress --title="Copy $result files" --percentage=0 --auto-close
 
Old 11-11-2013, 05:58 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you may try pv: http://linux.die.net/man/1/pv
http://www.youtube.com/watch?v=mTwBlPqRZO8

Last edited by pan64; 11-11-2013 at 05:59 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about "echo "$CALLER" | tr -s '[:upper:]' '[:lower:]'" thomas2004ch Linux - Software 5 03-13-2012 02:57 PM
Qt "cannot call constructor for""a function-style cast remove the redundant ::QBrush" Peterius Linux - Software 4 11-24-2010 04:57 PM
Problem "$value=`mpstat 1 1 | grep "Average"`;" Alias pipe return nothing adamlucansky Linux - General 8 09-25-2009 07:26 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 02:14 PM
When "function pointer" meets "template"... I can't get rid of this compiling er cyu021 Linux - Software 3 12-17-2004 07:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration