LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-26-2014, 04:21 PM   #1
krilen
Member
 
Registered: Mar 2004
Distribution: CentOS, FreeBSD
Posts: 42

Rep: Reputation: 15
Run bash script when I log in


Hi.

Have searched and searched but have not found what I am looking for. Maybe anyone behind another screen can help me.

Did not know where to post this thread so I went with the easiest.

I am running fedora 20 with mate, x86_64.

-----------------------------
Linux XXX.XXX.XXX 3.15.6-200.fc20.x86_64 #1 SMP Fri Jul 18 02:36:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
-----------------------------

I recently was the victim och the 16-bit bug in kernel 3.14 but it has been looking up now since the arrival och 3.15. But I still need to run "echo 1 > /proc/sys/abi/ldt16" to get the old program to run under wine.

That why I thought of creating a .sh script to run when I log in. The problem is that it works when I run it manually but noting happens when I but the script in .bash_profile.

This is the script (.wine16bit.sh)
-----------------------------
!/bin/bash
# A script to enable 16-bit for Wine
# 2014-07-25

/usr/bin/sudo /usr/bin/sh -c "echo 1 > /proc/sys/abi/ldt16"
-----------------------------

I have put it in bash_profile as /home/krister/.wine16bit.sh

I have hidden it and made sure it is able to be executed. As I said above it works when I run it after I have logged in. Have added to visudo my user so I can run scripts.

-----------------------------
krister ALL=NOPASSWD:/usr/bin/sh
-----------------------------

By the way my user (krister) is not root, just a normal user.

Anyone that can help me figure out what is wrong or hav another idea on how I can get the "echo" to run when I log in.

Thanks in advanced.

/Krister
 
Old 07-26-2014, 05:36 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
It works for me with modifications:

1. Your script should look as follows:

Code:
#!/bin/bash
# A script to enable 16-bit for Wine
# 2014-07-25

echo 1 > /proc/sys/abi/ldt16
2. Your .bash_profile should look as follows:

Code:
sudo /bin/sh /home/krister/.wine16bit.sh
3. Your sudoers should look as follows:

Code:
krister ALL = (root) NOPASSWD: /bin/sh
 
Old 07-27-2014, 12:26 AM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,825

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
or
if you have tested the script and KNOW ( 100%)it will not effect any other program or user
drop the shell script into /etc/profile.d
and reboot

but if it is incompatible with other programs .....
 
Old 07-27-2014, 01:15 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
If it is going to be set always, why not put in an init script such as rc.local? That way it gets set on boot, and no need to create complicated methods for all users to use to set it.
 
Old 07-27-2014, 06:52 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by jpollard View Post
If it is going to be set always, why not put in an init script such as rc.local?
Linux distributions commonly use /etc/sysctl.conf. Additionally Fedora (now?) has /etc/sysctl.d/ for local additions.


Quote:
Originally Posted by jpollard View Post
That way it gets set on boot, and no need to create complicated methods for all users to use to set it.
In this case it's quite valid to "create complicated methods", do check the comment in commit Id fa81511bb0bbb2b1aace3695ce869da9762624ff.


I would suggest the OP creates (or modifies) the script that starts WINE and not only add a "echo 1 > /proc/sys/abi/ldt16" before starting WINE but also a "echo 0 > /proc/sys/abi/ldt16" when exiting.
 
Old 07-27-2014, 08:35 AM   #6
krilen
Member
 
Registered: Mar 2004
Distribution: CentOS, FreeBSD
Posts: 42

Original Poster
Rep: Reputation: 15
First of all thanks for the help.

T3RM1NVT0R: I'am sorry to say that your solution don't work. It works when I run it manually after I have logged in (have to sudo it).

unSpawn: Your thoughts are interesting and I think that your solution would be best. Why enable 16-bit all of the time? But how would I make it do this? Could you point me in the right direction or give me a hint where to look. Should I modify the link that starts the program, how would I disable it when I quit the program?

This is the current link that is on my desktop to start the program:

-----------------------------------
env WINEPREFIX="/home/krister/.wine" wine C:\\windows\\command\\start.exe /Unix /home/krister/.wine/dosdevices/c:/users/krister/Start\ Menu/Programs/Hogia\ Family/Hogia\ HemEkonomi.lnk
-----------------------------------

Again thanks for all the help. This is why I love Linux, if someone has a question someone has an answer

/Krister
 
Old 07-27-2014, 10:06 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Ensure /etc/sudoers contains line:
Code:
krister ALL = (root) NOPASSWD: /usr/local/bin/wine16bit.sh st*
then save following script as "/usr/local/bin/wine16bit.sh" (owner and group root, mode 0550 should do):
Code:
#!/bin/bash
# A script to enable 16-bit for Wine
# 2014-07-25
case "$1" in
 start) echo 1 > /proc/sys/abi/ldt16;;
 stop)  echo 0 > /proc/sys/abi/ldt16;;
 *)     echo "wine16bit: [ start | stop ]"; exit 1;;
esac
exit 0
and save the following script as "/home/krister/bin/WINE_hhe.sh" (or whatever you'd like to call it, you own it, mode 0750):
Code:
#!/bin/bash --
sudo /usr/local/bin/wine16bit.sh start
env WINEPREFIX="/home/krister/.wine" wine C:\\windows\\command\\start.exe /Unix /home/krister/.wine/dosdevices/c:/users/krister/Start\ Menu/Programs/Hogia\ Family/Hogia\ HemEkonomi.lnk
sudo /usr/local/bin/wine16bit.sh stop
exit 0
...should about do it.
 
1 members found this post helpful.
Old 07-27-2014, 10:57 AM   #8
krilen
Member
 
Registered: Mar 2004
Distribution: CentOS, FreeBSD
Posts: 42

Original Poster
Rep: Reputation: 15
Thanks unSpawn

I had to disable the line that stopped 16-bit support otherwise it worked fine.

When the line was enable I got the same problem as before that told med I need to enable 16-bit

-----------------------------------------
[krister@lenovo ~]$ WINE_hhe.sh
fixme:exec:SHELL_execute flags ignored: 0x00000100
fixme:exec:SHELL_execute flags ignored: 0x00004100
[krister@lenovo ~]$ modify_ldt: Ogiltigt argument
err:winediag:build_module Failed to create module for "krnl386.exe", 16-bit LDT support may be missing.
err:module:attach_process_dlls "krnl386.exe16" failed to initialize, aborting
err:module:LdrInitializeThunk Main exe initialization for L"C:\\windows\\system32\\winevdm.exe" failed, status c0000142
^C
-----------------------------------------

The 16-bit must be enable the entire time when the program is running, tried using sleep but after the time ran out the program more or less crashed.

You don't know any other way to run the stop when I close the program?

Otherwise Thank you.

/Krister
 
Old 07-27-2014, 11:12 AM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
/proc/sys/abi/ldt16 is a global setting. It is either set or clear for all users.

So it is fairly obvious that it cannot be set to 0 without causing problems to active processes that require it.
 
Old 07-28-2014, 02:18 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by krilen View Post
You don't know any other way to run the stop when I close the program?
Create two symlinks (so you can create desktop icons for them or such):
Code:
ln -sf /home/krister/bin/WINE_hhe.sh /home/krister/bin/WINE_hhe_start
ln -sf /home/krister/bin/WINE_hhe.sh /home/krister/bin/WINE_hhe_stop
now modify "/home/krister/bin/WINE_hhe.sh" to look like this:
Code:
#!/bin/bash --
case "$0" in
*_hhe_start) sudo /usr/local/bin/wine16bit.sh start
 env WINEPREFIX="/home/krister/.wine" wine C:\\windows\\command\\start.exe /Unix /home/krister/.wine/dosdevices/c:/users/krister/Start\ Menu/Programs/Hogia\ Family/Hogia\ HemEkonomi.lnk;;
*_hhe_stop) sudo /usr/local/bin/wine16bit.sh stop;;
*) echo "No dice"; exit 1;;
esac
exit 0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run bash script automatically after the root log in Noazet Linux - Newbie 1 03-30-2014 07:23 PM
My BASH script work perfect when i run it manualy, but not when it run in the crontab roqarg Linux - Newbie 30 05-06-2010 02:37 PM
(Bash) Redirect all output from script to all.log and copy of errors to err.log hmsdefender Programming 5 03-05-2010 02:52 PM
Bash script for server log (namely var/log/messages) tenaciousbob Programming 17 05-24-2007 11:43 AM


All times are GMT -5. The time now is 02:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration