2

I have a command that I would like to run from a shell script:

LD_PRELOAD='/usr/$LIB/libstdc++.so.6' DISPLAY=:0 steam

This command is necessary to run Steam correctly on my system. If I try to run Steam without this command, the icon appears on the launcher then disappears again, leaving just a process that I have to end in system monitor.

If I cut and paste that command directly into a terminal, it works perfectly. Steam opens and works just fine, and the terminal sits there in the background giving output until Steam is closed again.

If I try to run that command from a shell script, it doesn't work anymore. The same problematic behavior shows up.

Interestingly, if I go into the terminal and type ./Steam.sh - which is the name of my script - Steam opens correctly.

Steam.sh is located in my home folder, and I run all the commands from my home folder in the terminal, and I have given execute permission to Steam.sh. I have also tried adding & to the end of the command in the shell script, but that hasn't helped.

Any idea why this command works differently depending on whether it's launched from a shell script or from a terminal? I thought shell scripts were supposed to be basically the same thing as running commands from a terminal.

  • I should clarify that I've seen other questions on this same issue, but none with answers, or at least none with answers that work for me. – Excrubulent Jan 15 '17 at 9:47
  • 1
    Well, what is the purpose of your script ? I mean, where does it run ? At login time ? From a .desktop shortcut ? It clearly is working from terminal, so there's something else that you're not telling us – Sergiy Kolodyazhnyy Jan 15 '17 at 10:09
  • It runs whenever I want to run Steam. I would like it to run whenever I click on it, but unfortunately that isn't working. There is nothing that I'm not telling you that I know of. If you have something more specific you would like to know, ask away. – Excrubulent Jan 15 '17 at 22:47
  • 1
    OK , so lets try couple things. Instead of setting those variables before steam command, set them on separate lines above it, as export DISPLAY=:0 , same thing with LD_PRELOAD. Ensure your DISPLAY variable is actually that - just echo $DISPLAY in terminal. If that doesn't work. Also, consider using /usr/lib/i386-linux-gnu/libstdc++.so.6 or /usr/lib/x86_64-linux-gnu/libstdc++.so.6 instead of the one you have there – Sergiy Kolodyazhnyy Jan 15 '17 at 23:27
  • Okay, putting them on separate lines didn't help, using export didn't help, and echo doesn't work because I don't have a terminal window when the problematic behaviour arises. I could run the script from a terminal, but as I've mentioned, the problem doesn't appear if I run it from terminal. Is there any way to see the value of $DISPLAY even if I run the script with a mouseclick? – Excrubulent Jan 16 '17 at 21:37
1

Because the default Terminal interpreter is Dash, where you are running the script in Bash. Bash features things that Dash doesn't.

Anyway you can fix Steam like this:

Before running Steam:

ln -sf /usr/lib/libstdc++.so.6.0.20 ~/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libstdc++.so.6

After running Steam:

rm $HOME/.steam/steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libstdc++.so.6
rm $HOME/.steam/steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libstdc++.so.6
  • So... how do I run it in Dash, since I want it to work the same way it runs in the terminal? Also, what do you mean about before running Steam & after running Steam? Do I need to run those commands every time? – Excrubulent Jan 15 '17 at 22:48
  • Although yes - dash is a minimal shell and differs from bash ,dash has nothing to do with the issue. Setting an environment variable preceding a command works in Dash as well. Try this in dash, FOO="bar" python -c "import os;print os.environ['FOO']" and you'll see "bar" being printed out. – Sergiy Kolodyazhnyy Jan 15 '17 at 22:58
  • Dash is what is run by default in the Terminal, where for running a script in Bash you have to write bash [script]. – Alberto Salvia Novella Jan 16 '17 at 18:59
  • The fix I suggest only needs to be entered once, but the commands in the "after running Steam" will only work after you have run Steam in the current user session at least once. – Alberto Salvia Novella Jan 16 '17 at 19:00
  • Okay, thanks for clarifying. I'd like to leave the problem as it is for now, so I can know when I've fixed the script. I'm fairly new to shell scripts on Linux, so I'd like to have an easily reproducable problem to solve, rather than fixing it straight away. Once I've figured out how to fix the script, I'll try fixing Steam properly. – Excrubulent Jan 16 '17 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.