Menu

Baffled by quotes

Help
Larry
2023-12-01
2023-12-01
  • Larry

    Larry - 2023-12-01

    I have a machine that I use to pass program updates between three people.
    I am trying to get a notification when someone is using scp to get the latest version.
    I keep getting unmatched quote errors.
    So far, I am simply trying to get one rsh line sent, which works fine, but now I am trying to get a notification.
    IP address & port number has been sanitized. Variable 'out' contains "randy - name of program and revision"

    #!/usr/bin/rexx
    
    address system "rsh larry@123.456.789.10 -p4546 'ps aux | grep randy | grep scp'" with output stem randy.
    
    out = word(randy.1,1) || " - " || substr(randy.1,84)
    
    say out
    
    sendstring = 'address system "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u larry)/bus /usr/bin/notify-send -t 0 """ || out || "'"
    
    say sendstring
    
    interpret sendstring
    

    Here's what I want the sendstring to say:

     

    Last edit: Larry 2023-12-01
  • Mike Protts

    Mike Protts - 2023-12-01

    I can see a mismatch of quotes in the sendstring = line, the first single quote is not being matched with the last as that's in double quotes. The number of double quotes around the notify-send payload will then not match, so will need fixing.

    I'm not sure why the interpret statement is needed here, it's very powerful when needed, but also totally opaque, so a comment explaining what it's expected to look like when run is essential. Usually when writing the comment the way to avoid interpret jumps out in better logic.

     
    👍
    1
    • Larry

      Larry - 2023-12-01

      Sorry, I edited my post to add "Here's what I want the sendstring to say:" but then I neglected to add the example.

      DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u larry)/bus /usr/bin/notify-send -t 0 "randy - Test 3.14"

      I think my problem is that I don't know enough about 'address system' .
      I have 'The Regina Rexx Interpreter Version 3.3', and the examples all seem to say that I need to quote the entire string.

      However, I did just figure out that I can use a variable to hold the string, which would not require an 'interpret'.

      So I did figure it out, but not until I read your response, which gave me a few clues.
      Thanks very much.

      Here's how I did it. I have a lot more to go into it, but the rest should be easy.

      #!/usr/bin/rexx
      
      address system "rsh larry@123.456.789.10 -p4242 'ps aux | grep randy | grep scp'" with output stem randy.
      
      out = '"' || word(randy.1,1) || " - " || substr(randy.1,84)|| '"'
      
      sendstring = 'DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u larry)/bus /usr/bin/notify-send -t 0 '
      
      sendstring = sendstring || out
      
      say sendstring
      
      address system sendstring
      
       

Log in to post a comment.