fixed submission problems

This commit is contained in:
Gregory Gauthier 2026-02-03 16:10:03 +00:00
parent 97c342693c
commit 273a0eb15c
4 changed files with 180 additions and 18 deletions

View File

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

28
tmp.py Normal file
View File

@ -0,0 +1,28 @@
# --------------------- DIAGNOSTICS: Prove temp file is created & readable ---------------------
print("\n--- TEMP FILE DIAGNOSTICS ---")
print(f"Current working directory: {os.getcwd()}")
print(f"Temp dir in use: {tempfile.tempdir}")
if os.path.exists(jcl_path): # jcl_path is the variable holding your temp file name/path
print(f"File exists: YES → {jcl_path}")
print(f"File size: {os.path.getsize(jcl_path)} bytes")
# Show basic permissions (octal, e.g. 0o644 = rw-r--r--)
st = os.stat(jcl_path)
print(f"Permissions (octal): {oct(st.st_mode & 0o777)}")
print(f"Owner UID: {st.st_uid} (your user should match os.getuid())")
# Try reading it back to prove readability
try:
with open(jcl_path, 'r') as f:
content = f.read()
print("File is readable! First 200 chars of content:")
print(repr(content[:200])) # repr() shows escapes/newlines clearly
print(f"... (total lines: {content.count('\n') + 1})")
except Exception as e:
print(f"Read failed: {e}")
else:
print("File exists: NO → something went wrong creating it")
print("--- END DIAGNOSTICS ---\n")

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
/*