Invoking yafc without opening a prompt?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

Invoking yafc without opening a prompt?

#1 Post by Rattlehead »

Hello, I have installed the console ftp client yafc (Yet Another Ftp Client), and I'm very happy with its bash-like syntax to move things around folders via FTP.
Now I'd like to automatize my operations a bit more with a script to get or put certain files, but I find the following problem: in the first line of my script, I have to open the ftp with this command

Code: Select all

yafc ftp://user:password@host/some/folder
when I do this, yafc opens its own prompt, so it doesn't reach my next yafc commands.

Anybody knows how to send several orders in succession to yafc without having the prompt showing up? My hope is it is an elemental redirection problem. Thank you

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#2 Post by trapster »

Code: Select all

#!/bin/bash
yafc  <<**
open ftp://username:password@somewhere/ 
ls 
rm -f dir/somefile.txt
rm -f dir/anotherfile.txt
put -f -r /home/user/*
close
**
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#3 Post by amigo »

That sort of syntax is pretty common for scripting commands for ftp clients -and is also used for scripting fdisk commands. I'd use something besides '**', though, like 'EOF' to avoid any possible probelems and for readability. MHO.

Shel
Posts: 103
Joined: Sat 11 Apr 2009, 17:33
Location: Seattle, WA, USA, or Southern France

#4 Post by Shel »

While Trapster's "here document" (q.v.) will work, you might want a more robust solution, particularly one that can handle errors and other exceptions. The classic solution here is the 'expect' scripting language, though I don't know if a Puppy package is available.

-Shel

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#5 Post by Rattlehead »

Thanks people, it's exactly what I was looking for. :D

As for the Expect language, it seems a bit of overkill to me, I just want to do a couple of fixed operations and I'm sure they do not generate errors, so bash is alright. But thank you, I did not know that one (how many computer languages are there? OMG...)

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#6 Post by amigo »

expect is not really a 'language'. It's a small program which can be used to automate what would ordinarily be interactive programs. There is a similar program called 'yes' which will answer 'yes' to any pauses a program makes when run in conjunction with 'yes'. expect is a more robust tool which can handle other answers bseides 'yes'. It has a more elaborate syntax which *could* be considered a language if you stretch the meaning of the word. Similarly, ImageMagick also has a script-like syntax when used from the command-line.

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#7 Post by Rattlehead »

Thank you for the information. I'll stick to plain bash anyway, because it's what I know best, and writing my tiny scripts makes me feel very 'hi-tech' :P

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#8 Post by technosaurus »

Sounds like a good candidate for a gtkdialog frontend. What is the size?
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#9 Post by Rattlehead »

What is the size?
Of Yafc, you mean? I've been looking for the pet file and I don't have it anymore, and i cannot find it in the forum either. :? But it was pretty small, that's for sure...

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#10 Post by technosaurus »

Busybox has ftpput ftpget and tftp ... as well as ftpd and tftpd ... should do most needs.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply