I had to indent your code for you to understand what you were doing.
See the lines in red. That's where the extra numbers are coming from -- the extra print statement to print the extra numbers. Changing it from %d to % stops it happening because you're feeding printf a weird enough command string to make it not "work". It'd be better to just not use printf at all, since you don't want it to print a number there. I'm guessing from how you used it that you're confused as to when printf prints where. The answer is, printf always prints to the same place no matter where you call it, so no extra printf in main is needed there.
Since bar is not returning a value, I've made it void. I've also added a return value and return statement for main, since you really do need one -- without it it returns an unpredictable value. I've had that come back to bite me when scripts using my programs saw the nonzero return, assumed that meant error, and died...
Your k variable is also redundant. You can just reuse it in the second loop instead of adding a brand new var. And your z variable doesn't have much point. Best to minimize the number of variables so you can tell what's going on...
As for opening an HTML file, that's not really HTML specific. The answer is, you run the program that handles the file. Or, for complicated enough GUI systems, you can run a command that decides what program to use and open it for you. OSX has this as the open command:
You should be able to use it like
[edit] I think I misunderstood you, and you want to interface your program with web pages and not just send your client to them. There's no simple way to do it, as it's not a particularly simple process; you should use a library like libcurl or an external program like wget. I think OSX comes with -lcurl, but doesn't come with wget.
Last edited by Corona688; 12-15-2009 at 05:51 PM..
Reason: fix typo in the fixed source
i am trying to write a script where in it will connect to remote servers and execute remote scripts to fetch some data and ftp it back to a main server. i would like to add a script where it will show some sort of status bar until such time that the expected files have been recieved.
something... (3 Replies)
hi all,
i'm currently working on an SGI IRIX system and a solaris system also. In order to transfer files across these two systems i use a storagetek tapedrive with dat tapes. i use TAR to transfer files to tape, roughly 20gb at a time. i'm looking for a simple script using bourne shell if... (1 Reply)
Hi all,
I want to print # like that in a progress bar..
For e.g We can notice that during installation ... but,how to do that?
Thnx,
sakthi. (4 Replies)
Hi all,
This is a reformed post to my earlier ones!!!!!!
I would like to know how to include a progress bar while using the cp...
I am copying a few huge files from cdrom but am unable to figure out ,how to give a progress bar!!!!!
I checked out other sites as well,but the issue here is... (1 Reply)
Hi friends,
how can I show a progress bar for any running process in the shell script.
For example when I am copying or compressing a file.
Thanks. (1 Reply)
hi all,
in shell script (ksh), how do i write a progress bar ?? i have a script which searches files and while its searching i am currently printing out "." and if it finds what its searching for the script prints out the name of the file e.g
..................
firstFile.txt... (2 Replies)
Hello, it's me again...:eek:
I need to create a progress bar in C, but i have no idea on how to do it.
i want it to output something like this:
Progress: 58%
But i can't get it to work. Could you please post an example progress bar written in ANSI C?
Thanks (4 Replies)
I'm trying to use this code to get a progress bar for cp:
"Can you get cp to give a progress bar like wget?"
But I'm getting these errors:
stat: illegal option -- c
usage: stat
awk: division by zero
input record number 1, file
source line number 4
I'm using Mac OS X 10.6... (1 Reply)
Hi Experts;
Im in the process of writing a shell script for enabling an IT operations to run archiving.We use netbackup. The script is complete, though there is one bit that i need help on. Im trying to have a progess bar for the procedure.I have gone through the man page of the command in... (5 Replies)