![]() |
|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
![]() |
|
Thread Tools | Display Modes |
|
|||
![]()
Hi,
Is it possible to have a shell script for : I want to view on ftp (in our network) the 4 lasts files saved (see their dates and weight) ? thank's for your help. |
|
||||
![]()
If you use an ftp client that can be scripted well enough and outputs the necessary date information, just filter the ftp clients directory listing through a program that can sort it appropriately, then filter that scripts output to tail -n 4.
both a shell alias or standalone script could wrap that for faster usage.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|||
![]()
I tried this script verifynas:
When i launch : sh verifynas Apr 22, it works fine. But if i launch it with: sh verifynas Apr 6, it doesn't work, problem with spaces Is it possible to do a "ls" sort by date and keep only the 4 lasts lines ? Or correct my script to it works ?? #!/bin/sh clear && ftp -n ip_server << END | grep $1" "$2 cd backup_folder ls quit END |
|
||||
![]()
Not reliably but some ftp daemons may have the ability to. The 'ls' and 'dir' commands in the ftp client, are basically just commands that tells the client to ask the server for a directory listing; I'm not sure if the extra (usually ls -l style) information is required.
Here's a test that finds the last 4 files in a directory, *if* they were created in the present or previous month: Code:
Terry@dixie$ ftp -a ftp.freebsd.org << END | grep -E "`date -v -1m +%b`|`date +%b`" | tail -n 4 | sort cd pub/FreeBSD ls quit END -rw-r--r-- 1 110 1002 51703 Apr 26 05:32 dir.sizes -rw-r--r-- 1 110 1002 25830058 Apr 26 05:07 ls-lR.gz drwxrwxr-x 7 110 1002 512 Apr 05 18:37 snapshots drwxrwxr-x 10 110 1002 512 Mar 14 09:29 ports Terry@dixie$ There's probably a few Perl modules on CPAN that can, and virtually every script language that supports arrays could pull off the task. (I would probably use AWK and a hand written look up table, but I'm to busy to check CPAN right now)
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|||
![]()
Hi,
First, speak french sorry for my english. To test the script i done : script_nas 22 Apr : print all backup dated Apr 22 What do you think about ? Thank' to your reply. Here my script_nas : Code:
#!/bin/sh clear && echo "Recherche à la date de "$1 $2 if [ $1 -le 9 ] then ftp -n nas << END | grep $2" "$1 #2 spaces user quest password cd JIN ls quit END else ftp -n nas << END | grep $2" "$1 #1 space user quest password cd JIN ls quit END fi Last edited by vermaden; 26th April 2010 at 10:43 AM. Reason: Use [ code ] tags. |
|
|||
![]()
Another approach using a 'netrc' file and a simple regular expression to deal with the spaces between then name of the month and the day.
A test: Code:
$ ./last4 Jul 9 Trying 127.0.0.1... Connected to localhost. 220 hercules.utp.xnet FTP server ready. 331 Password required for j65nko. 230- OpenBSD 4.7-current (GENERIC) #31780: Sat Apr 3 16:55:32 MDT 2010 230- 230- Welcome to OpenBSD: The proactively secure Unix-like operating system. 230- 230- Please use the sendbug(1) utility to report bugs in the system. 230- Before reporting a bug, please try to reproduce it with the latest 230- version of the code. With bug reports, please try to ensure that 230- enough information to reproduce the problem is enclosed, and if a 230- known fix for it exists, include that as well. 230- 230 User j65nko logged in. prompt off Interactive mode off. ls ARTICLES listing 150 Opening ASCII mode data connection for '/bin/ls'. 226 Transfer complete. quit 221 Goodbye. -rw-r--r-- 1 j65nko j65nko 45629 Jul 9 2007 apsfilter-obsd.xml -rw-r--r-- 1 j65nko j65nko 10698 Jul 9 2007 new-iso-itis.xml -rw-r--r-- 1 j65nko j65nko 1667 Jul 9 2007 pf-simple.xml
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
shell script with zenity | bsdnewbie999 | OpenBSD General | 5 | 24th April 2009 02:37 AM |
shell script compare md5 sum | bsdnewbie999 | Programming | 1 | 11th April 2009 02:20 PM |
incrementing within a shell script? | spiderpig | Programming | 5 | 29th September 2008 08:12 PM |
Shell Script. | bsdnewbie999 | Programming | 21 | 15th July 2008 07:54 AM |
shell script with input | c0mrade | Programming | 5 | 13th July 2008 04:33 AM |