ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to execute command in QSH script from external file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to execute command in QSH script from external file

    I am struggling with the problem of running the command list from the QSH scripts.

    I've got an external file: test.txt with line as follow
    Code:
    system "CHGAUT OBJ('my_obj') USER(*PUBLIC) DTAAUT(*RWX) OBJAUT(*ALL)"
    and the QSH script:

    Code:
    #!/bin/sh
    while IFS='' read -r line || [[ -n "$line" ]]; do
     $line
    done <test.txt
    I receive
    Character ' 'not valid for following string '"CHGAUT '
    I have tried also
    Code:
     eval $line
    and several others. Do you have any idea how to solve above problem?



  • #2
    solution
    Code:
    #!/bin/sh
    while IFS='' read -r line || [[ -n "$line" ]]; do echo "${line}" | xargs -l $() done <test.txt

    Comment


    • #3
      Why read the script line-by-line and then run each line? Why not just execute the whole script?

      Comment


      • #4
        You are right

        Comment

        Working...
        X