Page 1 of 1

Invoking yafc without opening a prompt?

Posted: Sun 23 Jan 2011, 14:39
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

Posted: Sun 23 Jan 2011, 15:13
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
**

Posted: Sun 23 Jan 2011, 18:27
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.

Posted: Sun 23 Jan 2011, 18:37
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

Posted: Mon 24 Jan 2011, 10:14
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...)

Posted: Mon 24 Jan 2011, 15:19
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.

Posted: Wed 26 Jan 2011, 13:47
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

Posted: Mon 07 Feb 2011, 06:09
by technosaurus
Sounds like a good candidate for a gtkdialog frontend. What is the size?

Posted: Thu 10 Feb 2011, 00:45
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...

Posted: Fri 11 Feb 2011, 03:16
by technosaurus
Busybox has ftpput ftpget and tftp ... as well as ftpd and tftpd ... should do most needs.