plink truncating commands

I'm using plink.exe on WinXP to run some commands on Z/OS BASH. My commands are interspersed with echo commands so that I can parse the output and work out what is where.

The first hundred or so commands run fine, but then one of them gets truncated. For example:
Input:

echo :end_logdetail:
echo Job Name : TfmMigration
echo :jobinfo:

What happens:

user@host:/dev> echo :end_logdetail:
:end_logdetail:
user@host:/dev> echo Job Name : Tf
Job Name : Tf
user@host:/dev> echo :jobinfo:
:jobinfo:

I just checked where in the input file the error occurs, and it's exactly 4444 bytes in, on line 116 (so it's done 115 successful commands before it goes wrong).

The command I'm using is:

plink -batch -pw xxxx user@host < "c:\dev\telnetcmd.txt" > "c:\dev\telnetout.txt"

The telnetcmd.txt is just a DOS text file with an "exit" command at the end. p.s. can anyone tell me how I can lay out my code on separate lines?

When I preview, all the line breaks are removed. Lets see if the same happens when I click Submit...
OK fixed it - it doesn't happen in Internet Explorer, I was using Firefox to post.

Copy-and-paste usually works, I'm told. You could try putting it in code tags, too.

Given that I don't see an error message in that output, are you sure the code's being executed incorrectly? It could be carriage returns from your input messing it up.

Definitely incorrect - the line in the script says:

echo Job Name : TfmMigration

What actually gets echoed is:

Job Name : Tf

And this only happens on one of the hundreds of identical commands in the script.

p.s. fixed the post layout by trying Internet Explorer instead of Firefox.

Yes, but do you see any error messages?

Perhaps a background job has printed output right in the middle of this, causing the broken line.

Without seeing what your script actually is it's difficult to tell anything at all.

No, there's no error message, just one of the commands gets truncated. My script is now slightly different and it's going wrong in the same way in a slightly different place, now line 109 byte offset 4289. Here is a snip around where it goes wrong:

echo :end_logsum:
echo Job Name : SrcVRMigrationExtractUKAddress.442
echo :jobinfo:

gives this:

hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> echo :end_logsum:
:end_logsum:
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> echo Job Name : SrcVRMigrationExtractUKAddres
Job Name : SrcVRMigrationExtractUKAddres
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> echo :jobinfo:
:jobinfo:
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
 

The "...Address.442" echo command has been truncated at "...Addres", some others are being truncated also.

For example, later on in the script:

echo :end_logsum:
echo Job Name : TfmVotersRollMigration.442
echo :jobinfo:

gives this:

hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> echo :end_logsum:
:end_logsum:
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> echo Job Name : TfmVotersRollMigration.442
Job Name : TfmVotersRollMigration.442
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> echo :
:
hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> 

This time it's the "echo :jobinfo:" that is being truncated to "echo :".

Later on, an echo command is truncated to just "ec" with an error message:

hibbsph@cs-uat-etl02:/software/opt/IBM/InformationServer/Server/DSEngine> ec
If 'ec' is not a typo you can run the following command to lookup the package that contains the binary:
    command-not-found ec
-bash: ec: command not found

This could be very dangerous if, for example, I did "rm *.bak" and it got truncated to "rm *"!

---------- Post updated at 04:58 PM ---------- Previous update was at 04:20 PM ----------

OK, I think I've resolved it... I have switched from using < to feed the script in, to using plink's -m "c:\dev\telnetcmd.txt" command line option.

1 Like

We can't even trust < in Windows CMD? Yikes! :eek: That is very strange, and very useful to know.

This is the only time I've ever known a program to miss out data passed in with the < operator so I suspect that this is something unusual that plink is doing with its input.