FTP MGET – Get Multiple Files Without Prompt
Every now and again I have to use FTP (and Secure FTP) from the command line, in fact it’s actually my preferred method as it keeps my knowledge of the syntax nice and sharp rather than relying on GUI clients (though if you do need a good free FTP, SFTP and FTPS application you should try FileZilla).
Today I had to retrieve a set of log files from a supplier, we can use the MGET command to fetch multiple files using wildcards (e.g. *.csv) but the default behaviour of MGET is to ask the user to confirm that they want to download every file – not very convenient if you’re talking about tens of thousands of logs! Instead of resting a book and a penlid on the ‘Y’ key (I’ve seen it done) you can turn off the interactive prompts simply by issuing the PROMPT command to toggle on/off the prompts.
Additionally if you’d like your FTP responses to be less wordy you can use the VERBOSE command which will pare down responses to the minimum.
type “prompt” will turn off the interactive mode. It is a toggle, entering it in again will turn it back on.
The _O_RELEASE variable reimnded me on a small trick I once used. A while ago (understatement), I had to write a script that could be executed on Oracle 7 and on Oracle 8. In Oracle 7 the dba_indexes table had normal and bitmapped indicators in the same column. In Oracle 8, they added a extra column regarding bitmap indexes. My dynamically created CREATE INDEX statements via a cursor where based on the info in DBA_INDEXES.The following gives you an idea how i solved it:define uniqueness= uniqueness column uniqueness new_value uniqueness -set termout off Table dba_indexes has changed in Oracle 8 Next piece of code switches the column name of the create index cursor.select decode(i.uniqueness, BITMAP ,i.uniqueness, NORMAL )’ uniquenessfrom dual where &&_O_RELEASE like 7%’ etc etc etcIF check3(i).s_segment_type=’INDEX’ THEN FOR r_index IN c_index(check3(i).s_segment_name,check3(i).s_owner) LOOP EXIT WHEN c_index%NOTFOUND; create_check3(i).r_statement := alter index ||r_index.idxowner||’.'||r_index.index_name ||chr(10) ||’REBUILD ONLINE’ ||chr(10) ||’PCTFREE ||r_index.pct_free ||chr(10) ||’storage’ ||chr(10) ||’( ||chr(10) ||’initial ||v_seg_initial||’K’ ||chr(10) ||’next ||v_seg_nextext||’K’ ||chr(10) ||’pctincrease ||r_index.pct_increase ||chr(10) ||’minextents ||r_index.min_extents ||chr(10) ||’maxextents ||v_max_extents ||chr(10) ||’freelists ||r_index.freelists ||chr(10) ||’)’ ||chr(10) ||’tablespace ||r_index.tablespace_name ||’;’ ; dbms_output.put_line(create_check3(i).r_statement); dbms_output.put_line( ‘); END LOOP;unionselect i.index_type’ uniquenessfrom dual where &&_O_RELEASE like 8%’; -set termout onset define ~….etc,etc.. Rebuild index CURSOR c_index( p_index IN CHAR , p_schema IN CHAR ) IS SELECT i.owner idxowner , i.index_name , ~uniqueness indextype , decode(i.uniqueness, UNIQUE’,’ UNIQUE ,’ ) uq , i.table_name , i.table_owner , i.tablespace_name , i.initial_extent , i.next_extent , i.min_extents , i.max_extents , i.pct_increase , i.freelists , i.pct_free , decode(c.constraint_type,’P',’PRIMARY KEY’ ,’U',’UNIQUE’ ,c.constraint_type) constype , c.constraint_name , c.status , c.owner consowner FROM sys.dba_indexes i , sys.dba_constraints c WHERE (c.table_name(+) = i.table_name AND c.constraint_name(+) = i.index_name AND c.owner(+) = i.table_owner) AND i.table_type = TABLE’ AND i.index_name = p_index AND i.owner = p_schema ORDER BY i.index_name ;