ubuntu - cannot run qtcreator or other programs - caching

I'm not an advanced user of Linux/Ubuntu.
yesterday, I thought it would be great to clean ram and cache as cleaning them could make my computer run faster. So, I did this as per this website.
tecmint link
sudo -i sync; echo 1 > /proc/sys/vm/drop_caches sync; echo 2 > /proc/sys/vm/drop_caches sync; echo 3 > /proc/sys/vm/drop_caches
exit
Now, when I run C++ code in Qt Creator, it's not compiling and giving back in application output this:
"Starting /home/jonmay/Documents/CPP_lessons/build-boqian_lessons-Desktop-Debug/boqian_lessons...
Cannot set up communication channel: Cannot create temporary directory
"/tmp/QtCreator.d13950": No space left on device
/home/jonmay/Documents/CPP_lessons/build-boqian_lessons-Desktop-Debug/boqian_lessons
exited with code -1"
I see the 'No space left on device'. So, I check the properties on computer. It is listing 0 byte free.
Netbeans is also not compiling.

Related

Why would this script work on Mac OS and not on Windows using Git Bash?

I wrote a site diagnostic script and have been testing it using iTerm2 on MacOS. A good portion of people that may consume this script use Windows and Git Bash (it's probably 50|50 Windows vs Mac OS): so not supporting Windows might not be an option.
I had someone here test out the script on their Windows PC and it immediately failed. Would anyone know why this function would succeed on Mac and fail on Windows?
_ping_test(){
# Define Error Codes & Messages Below:
local _success="0"
local _success_message="${_green}SUCCESS:${_reset_color} Ping Test Passed"
local _unknown_host="68"
local _unknown_host_message="${_red}ERROR:${_reset_color} Ping Test Failed on ${_url} - Unknown Host"
local _unrecognized_code="${_red}ERROR:${_reset_color} Ping Test Failed - Unrecognized Status Code${_ping_test} "
local _url="${1}.testdomain.net"
local _ping_url=$(ping -c 1 -q $_url &> /dev/null; echo $?)
if [ "${_ping_url}" == "${_success}" ] ; then
echo $_success_message
elif [ "${_ping_url}" == "${_unknown_host}" ] ; then
echo $_unknown_host_message
exit 1
elif true ; then
echo $_unrecognized_code
exit 1
fi
}
Running it returns the Unrecognized Code response on his computer, but given the same site is successful on my Mac.
I echo'd back $_url, and that returns the correct site. I also tried removing the &> /dev/null portion to hear back what the issue was, but it returned that it didn't recognize the command ping
Then I just ran the ping command directly in his Git Bash window, and that worked outside of the shell script.
I realize the ping test portion is a bit silly (it's used to exit the script if they input a bad URL), but the more valuable ssh commands that run later were also failing similarly
I managed to grab a Windows PC and TiL that the parameters you pass to ping follow a different paradigm based on OS:
-c means count on Mac OS
but
-c means compartmentalize on Windows which required admin access
fixed the params and then it worked

rc.local python script unrelated error: "getrandom indicates that the ..."

rc.local
/home/pi/home/gate/run.sh &
exit 0
/home/pi/home/gate/run.sh
#!/bin/sh
cd /home/pi/home/gate
export CREDENTIALS=credentials.json
sudo -E -H -u pi sh -c 'python3 localclient.py > log.txt 2>&1'
all I get in log.txt (update - plus some of my debug prints, initially I forgot to set PYTHONUNBUFFERED=1):
getrandom indicates that the entropy pool has not been initialized. Rather than continue with poor entropy, this process will block until entropy is available.
also I'm using sudo because su - pi didn't work (I got import errors, maybe because it didn't set $HOME?)
If I run run.sh manually (that is not automatically on startup), it works.
Also, the process uses all of the cpu (while blocking until more entropy?) and the pi gets hot.

I am looking for help trying to create a .sh file to run steam games through wines windows player

I have a computer running Ubuntu with retropie (emulationstation) which i can create .sh files to run linux based steam games through as they can be directly installed onto the computer. I have installed wine in order to play the windows based games and while I can run the files by going into windows steam and clicking play, I am looking for a way to create a .sh file that will allow me to play them through retropie. I can post some of the stuff ive tried i just am struggling with the formatting.
Let me know if i need to post anything else or fix something!
EDIT: Heres some of the code ive tried, the first i thinks should run the executable through wine but i cant get anything to output, the second is some code i found online which watches for the game to close as well so it can exit clean.
#!/bin/bash
wine ~/PlayOnLinux\'s\ virtual\ drives/Steam/drive_c/Program\
Files/Steam/steamapps/common/MortalKombat_KompleteEdition/DiscContentPC/MKKE.exe
#! /bin/bash
appid=$1
procname=$2
PREFIX=/home/rig-cade/PlayOnLinux\'s\ virtual\ drives
STEAM="/home/rig-cade/.wine-steam/drive_c/Program Files/Steam/Steam.exe"
export WINEDEBUG=-all
export WINEPREFIX=$PREFIX
if [[ ((`pgrep -f steam.exe -c` == 0)) && ((`pgrep -f Steam.exe -c` == 0)) ]]; then
optirun wine "$STEAM" -silent &
sleep 20
fi
echo "Running game"
wine "$STEAM" steam://rungameid/$appid &
sleep 15
echo "Starting checks"
status=`pgrep -f $procname -c`
if (( "$status" > 1 )); then
while (( "$status" > 1 )); do
sleep 5
status=`pgrep -f $procname -c`
done
wine "$STEAM" -shutdown &
fi
echo "Exiting"
I'm not 100% sure and I will test once I get done with work in a couple hours, but AFAIK the Steam URL protocol cannot be used with the command-line and so when you try this Steam is likely throwing a parsing error. If you add -console after -silent it should enable the Console tab and allow you to see an error message if you open the client.
Instead try one of
Only using the browser protocol without the "$STEAM" part so it's not trying to pass it as an argument to the client.
Using the Steam Command-line parameter -applaunch {appid},
where {appid} is replaced with the appid of the game to be run as you were already trying to do.

Problems with Raspian autostart via /etc/init.d

(Sorry for bad English, I'm German)
I'm trying (without success) to make my own program start automatically after booting (on a raspberry with raspian).
This is my script: (Note: You have to run this program with root privileges) (Note#2: There must be an empty file called "/home/testLog.txt" with write privileges for every user):
rm /etc/init.d/RMStart
echo "
#! /bin/sh
### BEGIN INIT INFO
# Provides: bla1
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: bla2
# Description: bla3
### END INIT INFO
#Switch case for the first parameter
case \"\$1\" in
start)
echo \"Start\" >> /home/testLog.txt
echo runlevel >> /home/testLog.txt
;;
stop)
echo \"Stop\" >> /home/testLog.txt
echo runlevel >> /home/testLog.txt
;;
restart)
echo \"Restart\" >> /home/testLog.txt
echo runlevel >> /home/testLog.txt
;;
*)
echo \"something else\" >> /home/testLog.txt
;;
esac
exit 0
" >> /etc/init.d/RMStart
chmod +x /etc/init.d/RMStart
update-rc.d RMStart remove #Remove older versions of this program ... in theory
update-rc.d RMStart defaults #Install new version of this program ... in theory
I've rebooted the raspberry, but the file /home/testLog.txt is still empty.
However, if I run the command: "/etc/init.d/RMStart" or "/etc/init.d/RMStart start" there is a new entry in /home/testLog.txt.
I would be thankful if anyone knows why the file /home/testLog.txt is still empty and how I could fix that.
Update:
I've tried a new installation script:
#RMS install script
chmod +x botComp.sh
rm /home/pi/RMS
pkill RMS
./botComp.sh
cp RMS /home/pi
chmod +x /home/pi/RMS
rm /etc/init.d/startRMS
sudo echo "#!/bin/sh
### BEGIN INIT INFO
# Provides: fqew
# Required-Start:
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 6
# Short-Description: sfwef
# Description: gfewf
### END INIT INFO
# Actions
case \"\$1\" in
start)
# START
su pi sh -c \" /home/pi/RMS \"
;;
stop)
# STOP
;;
restart)
# RESTART
;;
esac
exit 0 " >> /etc/init.d/startRMS
chmod +x /etc/init.d/startRMS
update-rc.d startRMS remove
update-rc.d startRMS defaults
The only difference I can see is the name of the script (/etc/init.d/startRMS instead of /etc/init.d/RMStart).
The script works, RMS is running.
It's not really a problem, but the script outputs:
insserv: script RMStart: service F already provided!
insserv: script RMStart: service F already provided!
I've added the line system("runlevel >> /home/pi/runlevelLog.txt"); In the program (RMS) but the content of /home/pi/runlevelLog.txt is: "unknown".
Does RMS start at runlevel 3? How I can I verify this? (I think runlevel 3 is ideal, because RMS needs Network Connection.) Thank you for your help.
is /etc/init.d/RMStart definitely being executed on reboot? use ls -lu to check the last time the file was accessed, wait a minute before rebooting, and repeat the command once you're back up. If the access time hasn't moved on then your script isn't being run which would explain the empty file as your script looks Ok.
You should also double check that update-rc.d has created symbolic links to your script in the appropriate run level directives e.g. does /etc/rc2.d/RMStart exist?
Another sanity check would be running your script using the symbolic links in the above directory rather than from /etc/init.d e.g. does /etc/rc2.d/RMStart
generate output in /home/testLog.txt?
Let me know what you find and we'll take it from there.
EDIT: attempting to replicate..
Well I managed to find my PI; the good news is that neither of us are going mad because it worked perfectly first time as we both believed it should.
I took a copy of your file, and I wrote a quick script (x) to check the exit codes from update-rc.d just to make 100% sure it wasn't complaining about anything.
Hopefully you can follow what I did in the screen shot above - I replicated the steps you followed almost exactly with a bit of extra checking along the way. The script certainly works as designed when called directly.
I then rebooted immediately and checked testLog.txt as soon soon as the system was up. You can see two entries in the file which is expected behaviour as init would have run /etc/rc6.d/K01RMStart as the system went down for reboot, and /etc/rc5.d/S01RMStart as it came up again.
Unfortunately this doesn't help you much.....
The only significant differnce between our tests was that I ran everything as root rather than using sudo. This shouldn't make a difference but the next logical thing for you to try is probably copying my test exactly and seeing if it works for you?
Not that this should be at all significant but I'm running Raspbian 8 (kernel 4.1.13+).
EDIT2: awesome... great stuff. I'd still like to know what the problem was but the main thing in that it's working.
System V based distributions will usually start in either level 3 or level 5, the difference being that level 5 will start the GUI whereas level 3 will start in text mode, their default runlevel is controlled by a line in /etc/inittab.
Debian(Raspian) distros are a bit different - (https://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit). They make no distinction between run levels 2-5 and leave it up the user to configure them to suit their requirements by adding services using the mechanism that's been causing us pain for the last 24 hours. They always start in level 5 unless a "init=" kernel boot parameter has been set, which you can do either at boot time or with a tool like bum or raspi-config.
The command runlevel will tell you the current level on raspian.
You can change the runlevel on the fly with telinit new_runlevel if you need to, but whatever you do, don't set the default runlevel to 0 :-)

Formatting Expect Script Inside of User Command in Bash Script

So I have three installers for NVIDIA's CUDA API -- the first is a driver and comes with nice silent install flag options (but you have to be root and have to have run level 3).
The second two follow are shown manually installing below (cut out the long mess of install afterwards for brevity)
[root]# sh cudatoolkit_4.1.28_linux_64_rhel5.x.run Verifying archive
integrity... All good. Uncompressing NVIDIA
CUDA.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Enter install path (default /usr/local/cuda, '/cuda' will be
appended): A previous version of CUDA was found in /usr/local/cuda/bin
Would you like to uninstall? (yes/no/abort): yes
In other words, I need to recognize:
"Enter install path" and output a '\n'
Now the tricky part is the uninstall may not be always be there. If it's not I need to simply wait for the install to finish, but if I see "Would you like to uninstall?" I need to output "yes" to complete.
The third and final installer's output is shown below....
[root]# sh gpucomputingsdk_4.1.28_linux.run Verifying archive
integrity... All good. Uncompressing NVIDIA GPU Computing
SDK............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Enter install path (default ~/NVIDIA_GPU_Computing_SDK):
/usr/local/CUDA_SDK Located CUDA at /usr/local/cuda If
this is correct, choose the default below. If it is not correct,
enter the correct path to CUDA Enter CUDA install path
(default /usr/local/cuda):
For this one, there is no uninstall action so it's seemingly a bit simpler.
I just need to detect "Enter install path" and output "/usr/local/CUDA_SDK\n" and then detect "Enter CUDA install path" and output "\n"
My idea was to use a pair of expect scripts -- one for each installer -- but due to the nesting within the double quotes of the command to switch to root, I'm having some difficulties with this. What I currently have is:
#!/bin/bash
CR="\"\n\""
YES="\"Yes\""
INSTALL_PATH_REQUEST="\"Enter install path\""
CUDA_PATH_REQUEST="\"Enter CUDA install path\""
UNINSTALL_REQUEST="\"Would you like to uninstall?\""
TOOLKIT=`ls -t cudatoolkit* | head -n 1`
TOOLKIT_EXPECT="sh $TOOLKIT"
SDK=`ls -t gpucomputingsdk* | head -n 1`
SDK_INSTALL_PATH="\"/usr/local/CUDA_SDK\n\""
SDK_EXPECT="sh $SDK"
/bin/su root -c "yum -q -y install expect expectk;
/sbin/init 3; sh `ls -t NVIDIA*|head -n 1` -s --update -a -X;
/usr/bin/expect <<EOF;
spawn $TOOLKIT_EXPECT
expect $INSTALL_PATH_REQUEST
send $CR
expect $UNINSTALL_REQUEST
send $YES
EOF
/usr/bin/expect <<EOF;
spawn $SDK_EXPECT
expect $INSTALL_PATH_REQUEST
send $SDK_INSTALL_PATH
expect $CUDA_PATH_REQUEST
send $CR
EOF
/sbin/init 5"
This switches to root properly (once the password is entered) and installs the driver with the built in options correctly. It then appears to spawn the second install process and enter the first argument (a carriage return), but seems to exit the second installer prematurely (e.g. I don't see the "yes" option.).
I feel like I'm pretty close, hopefully somebody can point me to where I'm going wrong and suggest the correct syntax.
NOTES:
I added the yum install command, as some of the machines I'm installing on didn't have expect (stock CentOS 6), so that saves me the trouble there....
Might be an issue with timeout here... not sure how long the installer takes.
The default expect timeout is 10 seconds, if it doesn't see the expected text in that time, it will proceed regardless, you could change the timeout values like so:
expect -timeout 100 $INSTALL_PATH_REQUEST
Also change your $YES from
YES="\"Yes\""
To:
YES="\"Yes\r\""
(Best to use \r instead of \n in $CR too)
It's also a good idea to expect some 'safety string' at the end of the install, for example:
expect -timeout 320 "Install Complete."
So the expect script doesn't terminate before the spawned process is complete.

Resources