Welcome to the Linux Foundation Forum!
Lab 4.1 fake_service.txt
ultraninja
Posts: 20
The fake_service.txt on the 4.1 Lab download link has messed up formatting. I reformatted and attached in case anyone else needs it.
Or copy/paste from here if you wish:
#!/bin/bash
# fake_service
# Starts up, writes to a dummy file, and exits
#
# chkconfig: 35 69 31
# description: This service doesn't do anything.
# Source function library
. /etc/sysconfig/fake_service
case "$1" in
start) echo "Running fake_service in start mode..."
touch /var/lock/subsys/fake_service
echo "$0 start at $(date)" >> /var/log/fake_service.log
if [ ${VAR1} = "true" ]
then
echo "VAR1 set to true" >> /var/log/fake_service.log
fi
echo
;;
stop)
echo "Running the fake_service script in stop mode..."
echo "$0 stop at $(date)" >> /var/log/fake_service.log
if [ ${VAR2} = "true" ]
then
echo "VAR2 = true" >> /var/log/fake_service.log
fi
rm -f /var/lock/subsys/fake_service
echo
;;
*)
echo "Usage: fake_service {start | stop}"
exit 1
esac
exit 0
# fake_service
# Starts up, writes to a dummy file, and exits
#
# chkconfig: 35 69 31
# description: This service doesn't do anything.
# Source function library
. /etc/sysconfig/fake_service
case "$1" in
start) echo "Running fake_service in start mode..."
touch /var/lock/subsys/fake_service
echo "$0 start at $(date)" >> /var/log/fake_service.log
if [ ${VAR1} = "true" ]
then
echo "VAR1 set to true" >> /var/log/fake_service.log
fi
echo
;;
stop)
echo "Running the fake_service script in stop mode..."
echo "$0 stop at $(date)" >> /var/log/fake_service.log
if [ ${VAR2} = "true" ]
then
echo "VAR2 = true" >> /var/log/fake_service.log
fi
rm -f /var/lock/subsys/fake_service
echo
;;
*)
echo "Usage: fake_service {start | stop}"
exit 1
esac
exit 0
0
Comments
-
0
-
I can't find anything wrong with the script. If you could be specific, it will be possible to evaluate your comment. The script in the class works fine where tested.
You have to say exactly what is wrong with formatting. When people cut and paste off pdf's the pdf reader sometimes screws up (in particular acroread screws up underscores and special characters, use a real pdf reader like evince please )0 -
My apologies for not being specific. Perhaps I'm doing something wrong but it appears there aren't newline characters in the file, causing the entire script to be one single line.
[sfox@localhost ~]$ wget https://lms.360training.com/scorm/linuxfoundation/LFS201/fake_service.txt --2015-05-12 10:51:32-- https://lms.360training.com/scorm/linuxfoundation/LFS201/fake_service.txt Resolving lms.360training.com (lms.360training.com)... 207.207.3.60 Connecting to lms.360training.com (lms.360training.com)|207.207.3.60|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 778 [text/plain] Saving to: ‘fake_service.txt’ 100%[========================================================>] 778 --.-K/s in 0s 2015-05-12 10:51:32 (153 MB/s) - ‘fake_service.txt’ saved [778/778] [sfox@localhost ~]$ cat fake_service.txt #!/bin/bash# fake_service# Starts up, writes to a dummy file, and exits## chkconfig: 35 69 31# description: This service doesn't do anything.# Source function library. /etc/sysconfig/fake_servicecase "$1" in start) echo "Running fake_service in start mode..." touch /var/lock/subsys/fake_service echo "$0 start at $(date)" >> /var/log/fake_service.log if [ ${VAR1} = "true" ] then echo "VAR1 set to true" >> /var/log/fake_service.log fi echo ;; stop) echo "Running the fake_service script in stop mode..." echo "$0 stop at $(date)" >> /var/log/fake_service.log if [ ${VAR2} = "true" ] then echo "VAR2 = true" >> /var/log/fake_service.log fi rm -f /var/lock/subsys/fake_service echo ;;*) echo "Usage: fake_service {start | stop}" exit 1esacexit 0[sfox@localhost ~]$
0 -
Yes you right I have confirmed it. It seems the online platform converted to Windows end of line characteristics (old problem). There are 3 other download files in the course (writeit.c signals.c ioscript.sh) that are affected as well, but while they have changed end of line characters, they look ok. We'll get them fixed in the next release.
There doesn't seem to be a way to post a file here in the forum (probably wise) but if you go to http://training.linuxfoundation.org/cm/LFS201, and log in with: username LFtraining password: Penguin2014, you can download all the files directly.
0 -
Thanks Jerry. I've logged in and grabbed the files in preparation for those upcoming labs.0
-
I downloaded the script for lab 4.1 from the link provided by Jerry and it worked. But I still don't understand why the script won't work when downloading from the class directly. I thought it was because there were windows newline characters hiding somewhere inside the script but after running dos2unix, it still doesn't work. Does anyone know why this doesn't work? How would you go about fixing the script (other than downloading a fresh copy from Jerry's link)?0
-
The file is broken, it is not worth figuring out. I thought it was fixed in the class but it wasn't, we'll try and take care of it.0
-
Hi Brucecurcio,
I waste 3 hours with this problem. The script code in the link of the 4.1 Lab in the spanish course is also unformated. If a copy/paste of the text in the pdf is performed, service utility throws that the file /etc/init.d/fake_service not exist, but the file is well placed and chkconfig shows the service in the correct runlevels. Some character must be hidden in the text and the file gives errors with service utility.
A way to fix the copied text from the pdf is the dos2unix utility.dos2unix name_of_the_corrupted_file
Once the file is well formatted the script runs without problems.
Would if be possible for the moderators to write a sticky post in the forum with the corrections to the material on each lesson?. It will be very hepfull.
Thanks!0 -
FToledano wrote:Hi Brucecurcio,
I waste 3 hours with this problem. The script code in the link of the 4.1 Lab in the spanish course is also unformated. If a copy/paste of the text in the pdf is performed, service utility throws that the file /etc/init.d/fake_service not exist, but the file is well placed and chkconfig shows the service in the correct runlevels. Some character must be hidden in the text and the file gives errors with service utility.
A way to fix the copied text from the pdf is the dos2unix utility.dos2unix name_of_the_corrupted_file
Once the file is well formatted the script runs without problems.
Would if be possible for the moderators to write a sticky post in the forum with the corrections to the material on each lesson?. It will be very hepfull.
What do you mean by "Sticky post in this forum"? If you experience a problem with one of your course materials, create a post under the related thread and past the material with all components there. Someone should be able to help as Jerry did.
Thanks!0 -
This was corrected (at least in the English version) last summer, and in this very thread there is a link to a web site (at training.linuxfoundation.org) where you can download a perfect copy without the dos2unix conversion. Furthermore, when I download the script from the download button it is also fine. If it is not, it is because you are downloading under Windows and it is doing a unix->dos conversion on you, which we can't do anything about. Furthermore, in the description of the exercise the actual full text of the script is there, and you can simply cut and paste it (in any language).
Unfortunately, when you use Windows programs (such as some browser downloads and pdf viewers such as acroread) these kinds of problems can occur as they try to "improve" upon unix customs.
As far as "stick notes" go, we update the course frequently to fix minor problems such as these and as long as we don't introduce new material or make more substantive changes you won't even notice.0 -
Thank you Istimsak and coop for the responses.
First of all I want to said that english is not my native language, I apologize for the errors. Thank you again for your patience and help.
All the browsers I use for this course are under Archlinux.
I'm enrolled in the LFSE spanish course and the material is not corrected yet. At this moment the lab 2.1 code link tested with Chrome, Firefox and QupZilla, seems like that:#!/bin/bash# fake_service# Starts up, writes to a dummy file, and exits## chkconfig: 35 69 31# description: This service doesn't do anything.# Source function library. /etc/sysconfig/fake_servicecase "$1" in start) echo "Running fake_service in start mode..." touch /var/lock/subsys/fake_service echo "$0 start at $(date)" >> /var/log/fake_service.log if [ ${VAR1} = "true" ] then echo "VAR1 set to true" >> /var/log/fake_service.log fi echo ;; stop) echo "Running the fake_service script in stop mode..." echo "$0 stop at $(date)" >> /var/log/fake_service.log if [ ${VAR2} = "true" ] then echo "VAR2 = true" >> /var/log/fake_service.log fi rm -f /var/lock/subsys/fake_service echo ;;*) echo "Usage: fake_service {start | stop}" exit 1esacexit 0
Istimsak :
What do you mean by "Sticky post in this forum"?
As I refer previously, english is not my native language, I want to mean something like this:
Stickying
As is mentioned in other moderation messages, the material corrections can't be done "at the moment" because some reasons, and I only wanted to suggest that a post in the top of the forum showing this issues may be helpfull, something like:Corrections: Lesson ...... Lesson 4 - If you experienced problems with the text showed in LAB 2.1 script code, download it from this site .......... (or whatever you want to explain or correct). Lesson 5 etc.
All people would see this post before read the lesson and to be prevented.
As you said, we can post questions in the forum but when I experienced problems trying to run service fake_service start, the first I thinked is that I was doing something wrong even more so when running chkconfig the fake_service appears ok and in the correct runlevels. After repeat the process a lot of times and read the lesson again several times I decide to test formating the file with dos2unix and all works ok.
After that I visit the forum to post it, but all was commented in this post. I added my comment yesterday only to show Brucecurcio user that after copy/paste the pdf code and formating the file with dos2unix utility, service can read the file without problems.
I try not to bother anyone, the sticky post was only a suggestion because the original post with the problem is dated from 2015 summer and the material in the spanish course isn't corrected yet. I thinked (because moderators have said it in others posts) that the correction of the material is not an easy task and this can help.coop wrote:As far as "stick notes" go, we update the course frequently to fix minor problems such as these and as long as we don't introduce new material or make more substantive changes you won't even notice.
As I said, I try to run the course under 3 different browsers included chrome under archlinux and other linux distros and seems that spanish course, at least for the LAB 2.1, isn't be updated.
In relation with the new material for the exam, are being applied the changes to the spanish course? If someone post some of them I can check it.
Thank you again.0 -
FToledano wrote:
As I refer previously, english is not my native language, I want to mean something like this:
Stickying
As is mentioned in other moderation messages, the material corrections can't be done "at the moment" because some reasons, and I only wanted to suggest that a post in the top of the forum showing this issues may be helpfull, something like:Corrections: Lesson ...... Lesson 4 - If you experienced problems with the text showed in LAB 2.1 script code, download it from this site .......... (or whatever you want to explain or correct). Lesson 5 etc.
All people would see this post before read the lesson and to be prevented.
As you said, we can post questions in the forum but when I experienced problems trying to run service fake_service start, the first I thinked is that I was doing something wrong even more so when running chkconfig the fake_service appears ok and in the correct runlevels. After repeat the process a lot of times and read the lesson again several times I decide to test formating the file with dos2unix and all works ok.
After that I visit the forum to post it, but all was commented in this post. I added my comment yesterday only to show Brucecurcio user that after copy/paste the pdf code and formating the file with dos2unix utility, service can read the file without problems.
I try not to bother anyone, the sticky post was only a suggestion because the original post with the problem is dated from 2015 summer and the material in the spanish course isn't corrected yet. I thinked (because moderators have said it in others posts) that the correction of the material is not an easy task and this can help.
Well, if we can created a new thread under this forum category, and update it with new material by editing the original post, it would seem possible. Perhaps an article or blog might be better with permanent link added to this thread.0
Categories
- All Categories
- 167 LFX Mentorship
- 219 LFX Mentorship: Linux Kernel
- 795 Linux Foundation IT Professional Programs
- 355 Cloud Engineer IT Professional Program
- 179 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 127 Cloud Native Developer IT Professional Program
- 112 Express Training Courses
- 112 Express Courses - Discussion Forum
- 6.2K Training Courses
- 48 LFC110 Class Forum - Discontinued
- 17 LFC131 Class Forum
- 35 LFD102 Class Forum
- 227 LFD103 Class Forum
- 14 LFD110 Class Forum
- 39 LFD121 Class Forum
- 15 LFD133 Class Forum
- 7 LFD134 Class Forum
- 17 LFD137 Class Forum
- 63 LFD201 Class Forum
- 3 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 2 LFD237 Class Forum
- 23 LFD254 Class Forum
- 697 LFD259 Class Forum
- 109 LFD272 Class Forum
- 3 LFD272-JP クラス フォーラム
- 10 LFD273 Class Forum
- 152 LFS101 Class Forum
- 1 LFS111 Class Forum
- 1 LFS112 Class Forum
- 1 LFS116 Class Forum
- 1 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 7 LFS144 Class Forum
- 3 LFS145 Class Forum
- 1 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 1 LFS157 Class Forum
- 33 LFS158 Class Forum
- 8 LFS162 Class Forum
- 1 LFS166 Class Forum
- 1 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 1 LFS178 Class Forum
- 1 LFS180 Class Forum
- 1 LFS182 Class Forum
- 1 LFS183 Class Forum
- 29 LFS200 Class Forum
- 736 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 14 LFS203 Class Forum
- 102 LFS207 Class Forum
- 1 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 301 LFS211 Class Forum
- 55 LFS216 Class Forum
- 48 LFS241 Class Forum
- 42 LFS242 Class Forum
- 37 LFS243 Class Forum
- 15 LFS244 Class Forum
- LFS245 Class Forum
- LFS246 Class Forum
- 50 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 154 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- 5 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 111 LFS260 Class Forum
- 159 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 20 LFS267 Class Forum
- 24 LFS268 Class Forum
- 29 LFS269 Class Forum
- 1 LFS270 Class Forum
- 199 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 9 LFW111 Class Forum
- 260 LFW211 Class Forum
- 182 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 782 Hardware
- 198 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 83 Storage
- 743 Linux Distributions
- 80 Debian
- 67 Fedora
- 15 Linux Mint
- 13 Mageia
- 23 openSUSE
- 143 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 348 Ubuntu
- 461 Linux System Administration
- 39 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 90 Linux Security
- 77 Network Management
- 101 System Management
- 46 Web Management
- 64 Mobile Computing
- 17 Android
- 34 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 19 Study Material
- 507 Programming and Development
- 285 Kernel Development
- 204 Software Development
- 1.8K Software
- 211 Applications
- 180 Command Line
- 3 Compiling/Installing
- 405 Games
- 309 Installation
- 97 All In Program
- 97 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)