Results 1 to 6 of 6

Thread: Open console from inside script

  1. #1
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,272

    Default Open console from inside script

    Formerly, under 13.2 I had a KDE Autostart item that ran in a console showing my appointments...

    Code:
    #!/usr/bin/env xdg-open[Desktop Entry]
    Comment=
    Exec=pal >/home/ion/TEMP/pal.out;cat /home/ion/TEMP/pal.out /home/ion/TEMP/addon >/home/ion/TEMP/result;more /home/ion/TEMP/result\s
    GenericName=
    Icon=
    Name=Pal
    Path=
    StartupNotify=true
    Terminal=1
    TerminalOptions=
    Type=Application
    X-KDE-SubstituteUID=false
    X-KDE-Username=
    It opened a console and I could page through it until it closed.

    Under 42.1 I added this script (calendar.sh) in my home bin directory to Settings>Configure Desktop>Startup and Shutdown>Autostart>Script File...

    Code:
    #! /bin/bash
    konsole -e pal >/home/ion/TEMP/pal.out;cat /home/ion/TEMP/pal.out /home/ion/TEMP/addon >/home/ion/TEMP/result;more /home/ion/TEMP/result
    But no console opens. What am I doing wrong?

    Thanks in advance.

  2. #2
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,178
    Blog Entries
    3

    Default Re: Open console from inside script

    That's a redirect fail (I think).

    Try (this is not tested):
    Code:
    konsole -e bash -c "pal >/home/ion/TEMP/pal.out;cat /home/ion/TEMP/pal.out /home/ion/TEMP/addon >/home/ion/TEMP/result;more /home/ion/TEMP/result" &
    openSUSE Leap 15.1; KDE Plasma 5;

  3. #3
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,272

    Default Re: Open console from inside script

    Quote Originally Posted by nrickert View Post
    That's a redirect fail (I think).

    Try (this is not tested):
    Code:
    konsole -e bash -c "pal >/home/ion/TEMP/pal.out;cat /home/ion/TEMP/pal.out /home/ion/TEMP/addon >/home/ion/TEMP/result;more /home/ion/TEMP/result" &
    Thank you for the suggestion, but it did not work. I will continue my research on it.

  4. #4
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,178
    Blog Entries
    3

    Default Re: Open console from inside script

    Sorry that it didn't work.

    Let me comment on what's wrong with your own first try.

    The first command (up to ";" ) runs pal in a konsole. But it redirects the output of "konsole" (hint -there probably isn't any) rather than the output of pal. By the time that the second command runs, "konsole" has already gone away (perhaps too quickly to see anything).
    openSUSE Leap 15.1; KDE Plasma 5;

  5. #5
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,272

    Default Re: Open console from inside script

    Quote Originally Posted by nrickert View Post
    Sorry that it didn't work.

    Let me comment on what's wrong with your own first try.

    The first command (up to ";" ) runs pal in a konsole. But it redirects the output of "konsole" (hint -there probably isn't any) rather than the output of pal. By the time that the second command runs, "konsole" has already gone away (perhaps too quickly to see anything).
    Excellent analysis of the problem! Re-wrote it as...

    Code:
    #! /bin/bash
    pal >/home/ion/TEMP/pal.out;cat /home/ion/TEMP/pal.out /home/ion/TEMP/addon >/home/ion/TEMP/result;konsole -e bash -c "more /home/ion/TEMP/result"
    ...and it works again. Many thanks o wise one.

  6. #6
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,178
    Blog Entries
    3

    Default Re: Open console from inside script

    Yes, much simpler and cleaner.
    openSUSE Leap 15.1; KDE Plasma 5;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •