Compare commits

...

3 Commits

Author SHA1 Message Date
Gregory Gauthier
881892eb39 remove debug code 2026-02-03 16:16:51 +00:00
Gregory Gauthier
a9c7d53b06 add password var to the runner 2026-02-03 16:16:12 +00:00
Gregory Gauthier
273a0eb15c fixed submission problems 2026-02-03 16:10:03 +00:00
4 changed files with 154 additions and 18 deletions

View File

@ -66,6 +66,8 @@ jobs:
echo "=== Debug: File detection complete ==="
- name: Upload to PDS and Submit JCL
env:
MVS_BATCH_PASSWORD: ${{ vars.MVS_BATCH_PASSWORD }}
if: steps.files.outputs.file != ''
run: |
echo "=== Debug: Starting upload/submit ==="

View File

@ -16,14 +16,11 @@ MVSHOST = "oldcomputernerd.com"
RDRPORT = 3505
MVS_PASSWORD = os.environ.get("MVS_BATCH_PASSWORD")
def upload_source(local_file, dataset_name, member_name, mvshost=MVSHOST):
"""Upload source code to MVS PDS member"""
# Read the source file
# full path will come from the job runner
# filepath = os.path.join(SRCLIB, local_file)
def create_jcl_payload(local_file, dataset_name, member_name):
with open(local_file, 'r') as f:
source_lines = f.readlines()
sysin = f.readlines()
# PDS member: Use IEBUPDTE
jcl = f"""
@ -39,31 +36,48 @@ def upload_source(local_file, dataset_name, member_name, mvshost=MVSHOST):
"""
# Append control statement, source lines, end, and terminator (no leading space on ./)
jcl += f"./ ADD NAME={member_name}\n"
for line in source_lines:
for line in sysin:
line = line.rstrip('\n')[:80]
jcl += line.ljust(80) + "\n"
jcl += "./ ENDUP\n"
jcl += "/*\n"
# Write JCL to temporary file and submit via netcat
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.jcl') as tmpfile:
tmpfile.write(jcl)
tmpfile_path = tmpfile.name
return jcl
def upload_source(local_file, dataset_name, member_name, mvshost=MVSHOST):
"""Upload source code to MVS PDS member"""
# Read the source file
# full path will come from the job runner
# filepath = os.path.join(SRCLIB, local_file)
payload = create_jcl_payload(local_file, dataset_name, member_name)
# Write JCL to temporary file and submit via netcat
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.jcl') as tmpfile:
tmpfile.write(payload)
tmpfile.flush()
tmpfile_path = tmpfile.name
try:
# Use cat to read the file and pipe to netcat
# cmd = f"cat {tmpfile_path} | nc -w3 {mvshost} {RDRPORT}"
cmd = f"nc -w 5 {mvshost} {RDRPORT} < {tmpfile_path}"
print(cmd)
subprocess.run(cmd, shell=True, check=True)
with open(tmpfile_path, 'rb') as f:
subprocess.run(
['nc', '-w', '5', mvshost, str(RDRPORT)],
input=f.read(),
check=True,
capture_output=True
)
print(f"Uploaded {local_file} to {dataset_name}({member_name})")
return 0
except subprocess.CalledProcessError as e:
print(f"Upload failed: {e}")
print("stderr:", e.stderr.decode(errors='ignore'))
return 1
finally:
# Clean up temp file
os.unlink(tmpfile_path)
# Clean up outside
#os.unlink(tmpfile_path)
print(f"Would have deleted {tmpfile_path}")
def submit_jcl(job, mvshost="oldcomputernerd.com"):
"""Submit JCL job from local directory"""

60
tmp/tmpfawu192m.jcl Normal file
View File

@ -0,0 +1,60 @@
//UPLOAD JOB (ACCT),'UPLOAD',
// USER=@05054,PASSWORD=PASSWD,
// CLASS=A,MSGCLASS=H,NOTIFY=@05054
//COPY EXEC PGM=IEBUPDTE,PARM=NEW
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DUMMY
//SYSUT2 DD DSN=@05054.SRCLIB.C,DISP=MOD,UNIT=SYSDA,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
./ ADD NAME=SIEVE08
#include<stdio.h>
#define LIMIT 10000
#define PRIMES 1000
int main()
{
int i,j,numbers[LIMIT];
int primes[PRIMES];
for (i=0;i<LIMIT;i++)
{
numbers[i]=i+2;
}
for (i=0;i<LIMIT;i++)
{
if (numbers[i]!=-1)
{
for (j=2*numbers[i]-2;j<LIMIT;j+=numbers[i])
numbers[j]=-1;
}
}
j = 0;
for (i=0;i<LIMIT&&j<PRIMES;i++)
if (numbers[i]!=-1)
primes[j++] = numbers[i];
printf("\n");
printf("PRIME NUMBERS BETWEEN 1 AND %d\n",LIMIT);
printf("TOTAL PRIMES FOUND: %d\n\n",PRIMES);
printf("LIST OF PRIMES:\n\n");
for (i=0;i<PRIMES;i++)
if (i % 20 == 0)
{
printf("\n %4d ",primes[i]);
}
else
{
printf("%4d ",primes[i]);
}
return 0;
}
./ ENDUP
/*

60
tmp/tmpfrgft9sq.jcl Normal file
View File

@ -0,0 +1,60 @@
//UPLOAD JOB (ACCT),'UPLOAD',
// USER=@05054,PASSWORD=PASSWD,
// CLASS=A,MSGCLASS=H,NOTIFY=@05054
//COPY EXEC PGM=IEBUPDTE,PARM=NEW
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DUMMY
//SYSUT2 DD DSN=@05054.SRCLIB.C,DISP=MOD,UNIT=SYSDA,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
./ ADD NAME=SIEVE08
#include<stdio.h>
#define LIMIT 10000
#define PRIMES 1000
int main()
{
int i,j,numbers[LIMIT];
int primes[PRIMES];
for (i=0;i<LIMIT;i++)
{
numbers[i]=i+2;
}
for (i=0;i<LIMIT;i++)
{
if (numbers[i]!=-1)
{
for (j=2*numbers[i]-2;j<LIMIT;j+=numbers[i])
numbers[j]=-1;
}
}
j = 0;
for (i=0;i<LIMIT&&j<PRIMES;i++)
if (numbers[i]!=-1)
primes[j++] = numbers[i];
printf("\n");
printf("PRIME NUMBERS BETWEEN 1 AND %d\n",LIMIT);
printf("TOTAL PRIMES FOUND: %d\n\n",PRIMES);
printf("LIST OF PRIMES:\n\n");
for (i=0;i<PRIMES;i++)
if (i % 20 == 0)
{
printf("\n %4d ",primes[i]);
}
else
{
printf("%4d ",primes[i]);
}
return 0;
}
./ ENDUP
/*