Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Odd output from shell when Powershell is executed

  1. #1

    Default Odd output from shell when Powershell is executed

    I work with Managed Service Providers that use Remote Monitor and Management environments to manage different Linux distros. One of the things we have been playing with is installing and executing simple PowerShell commands on Linux of different flavors. We had great success with several distros we have tested on but seem to have come across an odd issue with openSUSE I have yet to understand.

    This I am sure is just ignorance on my part but I can successfully install and execute Powershell at the terminal but when I use Powershell to produce scripted output it comes out blank. I know that's not a great explanation but I refer to a very basic command and a pipe to file verses just the command.

    See image below,

    If I run command and pipe it to a text file my output is a couple of newlines but if I run command without pipe I get a nice output as expected.

    Anyone ever seen this before or can duplicate it?





    We are on openSUSE 15.1

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,928

    Default Re: Odd output from shell when Powershell is executed

    Welcome to the openSUSE forums.

    Hm, like you I find this very strange. The output redirection (btw, this is not "piping") should work regardless of the nature of the program.

    This works as expected here:
    Code:
    henk@boven:~> cd /tmp
    henk@boven:/tmp> /usr/bin/ksh -c "ls -l"
    total 0
    drwx------ 2 henk wij   40 Feb 18 09:02 Temp-04598237-2279-48ee-abf9-d180b79a3f68
    drwx------ 2 henk wij   40 Feb 18 09:02 Temp-32efc675-ab68-445d-a283-0e859fd4fb0b
    drwx------ 2 henk wij  120 Feb 18 08:59 akonadi-henk.IBoJBS
    drwxr-xr-x 2 henk wij   60 Feb 18 10:18 closeditems
    drwx------ 2 henk wij   60 Feb 18 19:43 firefox
    drwx------ 2 kdm  kdm   60 Feb 18 08:59 kde-kdm
    drwx------ 2 kdm  kdm   60 Feb 18 08:59 ksocket-kdm
    drwx------ 3 root root  60 Feb 18 08:59 systemd-private-5047a082c294484ba1bd1d86e3624eb8-apache2.service-5D8OiL
    drwx------ 3 root root  60 Feb 18 08:59 systemd-private-5047a082c294484ba1bd1d86e3624eb8-ntpd.service-t0VhQ5
    drwx------ 3 root root  60 Feb 18 08:59 systemd-private-5047a082c294484ba1bd1d86e3624eb8-rtkit-daemon.service-VYpoSW
    henk@boven:/tmp> /usr/bin/ksh -c "ls -l" > aap
    henk@boven:/tmp> cat aap
    total 0
    drwx------ 2 henk wij   40 Feb 18 09:02 Temp-04598237-2279-48ee-abf9-d180b79a3f68
    drwx------ 2 henk wij   40 Feb 18 09:02 Temp-32efc675-ab68-445d-a283-0e859fd4fb0b
    -rw-r--r-- 1 henk wij    0 Feb 18 19:54 aap
    drwx------ 2 henk wij  120 Feb 18 08:59 akonadi-henk.IBoJBS
    drwxr-xr-x 2 henk wij   60 Feb 18 10:18 closeditems
    drwx------ 2 henk wij   60 Feb 18 19:43 firefox
    drwx------ 2 kdm  kdm   60 Feb 18 08:59 kde-kdm
    drwx------ 2 kdm  kdm   60 Feb 18 08:59 ksocket-kdm
    drwx------ 3 root root  60 Feb 18 08:59 systemd-private-5047a082c294484ba1bd1d86e3624eb8-apache2.service-5D8OiL
    drwx------ 3 root root  60 Feb 18 08:59 systemd-private-5047a082c294484ba1bd1d86e3624eb8-ntpd.service-t0VhQ5
    drwx------ 3 root root  60 Feb 18 08:59 systemd-private-5047a082c294484ba1bd1d86e3624eb8-rtkit-daemon.service-VYpoSW
    henk@boven:/tmp>
    Using ksh instead of pwsh (not installed here). You could try somehing like that as root also. But it is a shot in the dark.
    Henk van Velden

  3. #3
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    28,103
    Blog Entries
    15

    Default Re: Odd output from shell when Powershell is executed

    Hi
    Have you tried the rc2 version?

    On openSUSE Leap 151.1 (I only run as my user...);

    Code:
    pwsh -command "get-module -listavailable"
    
    
        Directory: /data/applications/powershell-7.0.0-rc.2-linux-x64/Modules
    
    ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
    ---------- -------    ---------- ----                                --------- ----------------
    Manifest   1.2.4.0               Microsoft.PowerShell.Archive        Desk      {Compress-Archive, Expand-Archive}
    Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core      {Start-Transcript, Stop-Transcript}
    Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core      {Add-Content, Clear-Content, Clear-ItemProperty, Join-…
    Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core      {Get-Credential, Get-ExecutionPolicy, Set-ExecutionPol…
    Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core      {Export-Alias, Get-Alias, Import-Alias, New-Alias…}
    Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-P…
    Script     2.2.3                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-Rol…
    Script     2.0.5                 PSDesiredStateConfiguration         Core      {Configuration, New-DscChecksum, Get-DscResource, Invo…
    Script     2.0.0      rc2        PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, R…
    Binary     2.0.3                 ThreadJob                           Desk      Start-ThreadJob
    
    pwsh -command "get-module -listavailable" > test.txt
    
    cat test.txt
    
    
        Directory: /data/applications/powershell-7.0.0-rc.2-linux-x64/Modules
    
    ModuleType Version    PreRelease Name                                PSEdition
    ---------- -------    ---------- ----                                ---------
    Manifest   1.2.4.0               Microsoft.PowerShell.Archive        Desk     
    Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core     
    Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core     
    Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core     
    Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core     
    Script     1.4.6                 PackageManagement                   Desk     
    Script     2.2.3                 PowerShellGet                       Desk     
    Script     2.0.5                 PSDesiredStateConfiguration         Core     
    Script     2.0.0      rc2        PSReadLine                          Desk     
    Binary     2.0.3                 ThreadJob                           Desk
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  4. #4

    Default Re: Odd output from shell when Powershell is executed

    Let me go update that pwsh to RC.2 and see.

  5. #5

    Default Re: Odd output from shell when Powershell is executed

    Yes we are on RC2,

    same command as you ran but I get 5 newlines.

    But if I run:

    pwsh -v > version.txt I get output of version in text file so it appears to be more about the returned output then the app.



    even pwsh -command get-date > date.txt fails with 4 newlines...

  6. #6
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    28,103
    Blog Entries
    15

    Default Re: Odd output from shell when Powershell is executed

    Quote Originally Posted by CubertTheDweller View Post
    Yes we are on RC2,

    same command as you ran but I get 5 newlines.

    But if I run:

    pwsh -v > version.txt I get output of version in text file so it appears to be more about the returned output then the app.



    even pwsh -command get-date > date.txt fails with 4 newlines...
    Hi
    If you run as a user rather than root, does it change?

    Code:
    pwsh -v > version.txt
    cat version.txt 
    PowerShell 7.0.0-rc.2
    
    pwsh -command get-date > date.txt
    cat date.txt 
    
    Tuesday, February 18, 2020 2:21:04 PM
    What is the default shell your using?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  7. #7

    Default Re: Odd output from shell when Powershell is executed

    Yes sam if I run as a normal user.

    Using bash as shell.

  8. #8

    Default Re: Odd output from shell when Powershell is executed

    interesting tidbit, fired up another instance of openSUSE and can not duplicate issue.

    2 pretty much blank instances, one terminal only the other with graphical desktop. desktop works fine but server does not..

  9. #9

    Default Re: Odd output from shell when Powershell is executed

    Quote Originally Posted by CubertTheDweller View Post
    I work with Managed Service Providers that use Remote Monitor and Management environments to manage different Linux distros. One of the things we have been playing with is installing and executing simple PowerShell commands on Linux of different flavors. We had great success with several distros we have tested on but seem to have come across an odd issue with openSUSE I have yet to understand.

    This I am sure is just ignorance on my part but I can successfully install and execute Powershell at the terminal but when I use Powershell to produce scripted output it comes out blank. I know that's not a great explanation but I refer to a very basic command and a pipe to file verses just the command.

    See image below,

    If I run command and pipe it to a text file my output is a couple of newlines but if I run command without pipe I get a nice output as expected.

    Anyone ever seen this before or can duplicate it?






    We are on openSUSE 15.1
    Hi,

    I don't have that program/utility at hand, but taking a guess at your issue you could try redirecting stderr to the file as well, try.

    Code:
    /usr/bin/pwsh -command "get-module-list-available" > ./postoutput.txt 2>&1
    If that succeeded then it has something to do with FD's, if not I don't have any idea...
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  10. #10

    Default Re: Odd output from shell when Powershell is executed

    Nope same result, 5 new lines in output text file.

Page 1 of 2 12 LastLast

Posting Permissions

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