Skip to content

Instantly share code, notes, and snippets.

@ghitti
Created July 23, 2019 12:10
Show Gist options
  • Save ghitti/49f83b6240306fb0a9c297331b1fcbcc to your computer and use it in GitHub Desktop.
Save ghitti/49f83b6240306fb0a9c297331b1fcbcc to your computer and use it in GitHub Desktop.
Bootstrap Python on IBM i
create or replace table qtemp.ftpcmd(cmd char(240)) on replace delete rows;
create or replace table qtemp.ftplog(line char(240)) on replace delete rows;
insert into qtemp.ftpcmd(CMD) values
('anonymous anonymous@example.com')
,('namefmt 1')
,('lcd /tmp')
,('cd /software/ibmi/products/pase/rpms')
,('bin')
,('get README.md (replace')
,('get bootstrap.tar.Z (replace')
,('get bootstrap.sh (replace')
with nc
;
CL:OVRDBF FILE(INPUT) TOFILE(QTEMP/FTPCMD) MBR(*FIRST) OVRSCOPE(*JOB);
CL:OVRDBF FILE(OUTPUT) TOFILE(QTEMP/FTPLOG) MBR(*FIRST) OVRSCOPE(*JOB);
CL:FTP RMTSYS('public.dhe.ibm.com');
CL:QSH CMD('touch -C 819 /tmp/bootstrap.log; /QOpenSys/usr/bin/ksh /tmp/bootstrap.sh > /tmp/bootstrap.log 2>&1');
select
case when (message_tokens = X'00000000')
then 'Bootstrapping successful! Review /tmp/README.md for more info'
else 'Bootstrapping failed. Consult /tmp/bootstrap.log for more info'
end as result
from table(qsys2.joblog_info('*')) x
where message_id = 'QSH0005'
order by message_timestamp desc
fetch first 1 rows only;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment