Author Topic: Linux 101  (Read 464 times)

Offline GOTHBITES

  • Hero Member
  • *****
  • Posts: 749
  • Oh I get it now. Windows 8 is a Bigger Sham
Linux 101
« on: February 12, 2013, 07:56:41 AM »
Hello

I am in need of help with a Linux Question. I'm in a Linux class basic Linux lol and the Instructor is having us trying to run or execute a .bat file in shell however the directions in the ebook we are using is in winblows.

Its a KnockKnock joke go figure

Quote
Exercise

@ ECHO OFF
TITLE "knockknock.bat - The KnockKnock joke game!"
COLOR OE
CLS
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
SET /p.reply="KnockKnock! D:>"
CLS
IF NOT %reply%=="Who is there?"
Echo "Sorry, but you are not playing the game right!" GOTO:EOF)
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
SET /p reply="Orange D:>"
CLS
IF NOT %reply%=="Orange who?"
(ECHO "Sorry,but you are not playing the game right!"GOTO :EOF)
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO"Orange you glad you've written your first windows shell script?"
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
See even the says Windows shell. Would  anybody know how to run these and other .bat files in Linux

Thank you in advance
« Last Edit: February 12, 2013, 07:58:17 AM by GOTHBITES »
UPDATED!! ASUS U52F Notebook i5 CPU,  4Gb ram, 640Gb Hard drive Dual-Boot Win 7Pro/KDE 4 3.2.18-pclos2.bfs

ASUS U50F notebook i3 4Gb Ram. 500 GB hard drive dual-boot Win 7/ KDE 3.2.18-pclos2.pae.bfs    Of course thats just my opinion I could wrong

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10610
  • MLUs Forever!
Re: Linux 101
« Reply #1 on: February 12, 2013, 08:34:37 AM »
Quote
I'm in a Linux class basic Linux lol and the Instructor is having us trying to run or execute a .bat file in shell however the directions in the ebook we are using is in winblows.

Why would anyone attempt to run a Windows command, or executable file in Linux?

Are you supposed to re-write it in bash?

Confused   ???
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline GOTHBITES

  • Hero Member
  • *****
  • Posts: 749
  • Oh I get it now. Windows 8 is a Bigger Sham
Re: Linux 101
« Reply #2 on: February 12, 2013, 09:00:19 AM »
Quote
I'm in a Linux class basic Linux lol and the Instructor is having us trying to run or execute a .bat file in shell however the directions in the ebook we are using is in winblows.

Why would anyone attempt to run a Windows command, or executable file in Linux?

Are you supposed to re-write it in bash?

Confused   ???

AS John McClain once said in the Movie Die Hard "Welcome to the party! Pal." 
This is one of the two classes that are needed to take for the Linux certification for Comptia.

And Yes Just17 I believe we are suppose to use Bash Commands and use Shell.  We just did another exercise vi or vim.

The instructor maybe a little confused and if they are confused then We are in serious trouble. I seriously want to drop the class and go to someone with a better understanding or have Tex and the rest of the crew come in and sub for this semester.
 
UPDATED!! ASUS U52F Notebook i5 CPU,  4Gb ram, 640Gb Hard drive Dual-Boot Win 7Pro/KDE 4 3.2.18-pclos2.bfs

ASUS U50F notebook i3 4Gb Ram. 500 GB hard drive dual-boot Win 7/ KDE 3.2.18-pclos2.pae.bfs    Of course thats just my opinion I could wrong

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10610
  • MLUs Forever!
Re: Linux 101
« Reply #3 on: February 12, 2013, 09:09:18 AM »
So the exercise is to write a  bash script that has the same functionality as the Win bat file?

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline pags

  • Hero Member
  • *****
  • Posts: 2518
  • Keep it clean.
Re: Linux 101
« Reply #4 on: February 12, 2013, 11:45:32 AM »
Do you even have the complete .bat file?  I see label references (GOTO:EOF), but no labels...

If this is an assignment (as just17 is trying to find out), then I would have to respectfully decline to do the work for you.

That doesn't mean we can help point you in the right direction.
 ;)

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10610
  • MLUs Forever!
Re: Linux 101
« Reply #5 on: February 12, 2013, 12:26:25 PM »
Do you even have the complete .bat file?  I see label references (GOTO:EOF), but no labels...

If this is an assignment (as just17 is trying to find out), then I would have to respectfully decline to do the work for you.

That doesn't mean we can help point you in the right direction.
 ;)

pags .......  even that idea --- to rewrite the .bat file as an exercise  ---  seems rather unlikely as it presumes one already has knowledge of the commands in the .bat file sufficiently to understand how it works so it can be translated.

I would think that is hardly a requirement for Linux 101 ........

so even more confused .....

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline pags

  • Hero Member
  • *****
  • Posts: 2518
  • Keep it clean.
Re: Linux 101
« Reply #6 on: February 12, 2013, 12:45:24 PM »
I hear ya...

Actually, converting would be harder than from scratch, as it pre-supposes knowledge of both command sets, and the commonalities between them.

I think GOTHBITES needs to respond, or we'll never know what's being asked for...

Online Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6373
  • I'm going South
Re: Linux 101
« Reply #7 on: February 12, 2013, 12:46:05 PM »
Would using a DOS emulator be considered cheating? There are a few in the repo....

(On the other hand, editing the batch file so that something like dosbox understands it might be as time-consuming as starting from scratch with bash.)
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline ghostbunny

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1173
Re: Linux 101
« Reply #8 on: February 12, 2013, 01:40:48 PM »
Hi,

that's a really strange task to convert this script to bash.

But if it help here is my interpretation in bash script.

Code: [Select]
#!/bin/bash

clear
echo "KnockKnock!"
sleep 1
clear

read ANSWER

if [ "$ANSWER" != "Who is there?" ]; then

echo "Sorry, but you are not playing the game right!"
exit 1
fi

echo "Orange"
sleep 1
clear
read ANSWER2

if [ "$ANSWER2" != "Orange who?" ]; then 

echo "Sorry, but you are not playing the game right!"
exit 1
fi
sleep 1
clear
echo "Orange you glad you've written your first linux shell script?"

exit 0
The full life is a big mess

PS:
I'm German. Sorry because of possible mistakes in my written messages xD


Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3980
Re: Linux 101
« Reply #9 on: February 12, 2013, 04:17:58 PM »
Well, it would help if you had your batch syntax right! The correct code (according to wine) is:
Code: [Select]
@echo off
title "knockknock.bat - the knockknock joke game!"
color oe
cls
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
set /p.reply="knockknock! d:>"
cls
if not %reply%=="who is there?"
(echo "sorry, but you are not playing the game right!" goto:eof)
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
set /p reply="orange d:>"
cls
if not %reply%=="orange who?"
(echo "sorry,but you are not playing the game right!"goto :eof)
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo "orange you glad you've written your first windows shell script?"
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .

I've dropped it to lower case as the first step to convert to a shell script. Windows isn't case sensitive and bash is. If you save it with a .bat suffix even kwrite will recognise the syntax!

However, it won't run in bash because although some of the basic syntax of batch and bash is similar (especially pipes and redirection), the commands are different.

As pags said, it's not clear what the task is. Are you supposed to install a batch interpreter into Linux? (That could be a reasonable goal as batch is just a primitive shell language, and wine includes a Linux version.) Are you supposed to convert the commands to some GNU shell equivalents? Does the instructor not know the difference? (Oh dear!)
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline GOTHBITES

  • Hero Member
  • *****
  • Posts: 749
  • Oh I get it now. Windows 8 is a Bigger Sham
Re: Linux 101
« Reply #10 on: February 13, 2013, 07:12:09 PM »
Hi,

that's a really strange task to convert this script to bash.

But if it help here is my interpretation in bash script.

Code: [Select]
#!/bin/bash

clear
echo "KnockKnock!"
sleep 1
clear

read ANSWER

if [ "$ANSWER" != "Who is there?" ]; then

echo "Sorry, but you are not playing the game right!"
exit 1
fi

echo "Orange"
sleep 1
clear
read ANSWER2

if [ "$ANSWER2" != "Orange who?" ]; then  

echo "Sorry, but you are not playing the game right!"
exit 1
fi
sleep 1
clear
echo "Orange you glad you've written your first linux shell script?"

exit 0

Ha ha ha thats cool Now I see. I must try this is in the vi editor . Now to add insult to injury, the text book  comes with its on Linux disk  Fedora 13. That tells you how far behind they are fedora is now on 18.
Im gonna share this with my instructor  hopefully this will prepare for next semester lol this.

No whats strange is that instructions that were given to us tells you how do it in windows, which was easy enough, but then  she say she wants this done in the virtual Linux box and she doesn't quite know how to do this herself.  sounds like fun huh?

I must Thank You again You Rock my dear Sir!!
« Last Edit: February 13, 2013, 07:20:27 PM by GOTHBITES »
UPDATED!! ASUS U52F Notebook i5 CPU,  4Gb ram, 640Gb Hard drive Dual-Boot Win 7Pro/KDE 4 3.2.18-pclos2.bfs

ASUS U50F notebook i3 4Gb Ram. 500 GB hard drive dual-boot Win 7/ KDE 3.2.18-pclos2.pae.bfs    Of course thats just my opinion I could wrong

Offline GOTHBITES

  • Hero Member
  • *****
  • Posts: 749
  • Oh I get it now. Windows 8 is a Bigger Sham
Re: Linux 101
« Reply #11 on: February 13, 2013, 07:18:54 PM »
Do you even have the complete .bat file?  I see label references (GOTO:EOF), but no labels...

If this is an assignment (as just17 is trying to find out), then I would have to respectfully decline to do the work for you.

That doesn't mean we can help point you in the right direction.
 ;)

You my dear sir are silly, but thanks for keeping me honest LMAO.  no it was an assignment , however seeing how nobody in the class ,including the instructor, could do it, we were told to forget it. but like I said earlier I just want to at least see how it could have been done and send it to my instructor.

There is a guy in class who announces to everyone he gets help from his brother,
so I am not the only one outsourcing ;D ;D ;D ;D ;D ;D

thank you
« Last Edit: February 14, 2013, 03:30:43 AM by GOTHBITES »
UPDATED!! ASUS U52F Notebook i5 CPU,  4Gb ram, 640Gb Hard drive Dual-Boot Win 7Pro/KDE 4 3.2.18-pclos2.bfs

ASUS U50F notebook i3 4Gb Ram. 500 GB hard drive dual-boot Win 7/ KDE 3.2.18-pclos2.pae.bfs    Of course thats just my opinion I could wrong

Offline GOTHBITES

  • Hero Member
  • *****
  • Posts: 749
  • Oh I get it now. Windows 8 is a Bigger Sham
Re: Linux 101
« Reply #12 on: February 13, 2013, 07:36:34 PM »
Well, it would help if you had your batch syntax right! The correct code (according to wine) is:
Code: [Select]
@echo off
title "knockknock.bat - the knockknock joke game!"
color oe
cls
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
set /p.reply="knockknock! d:>"
cls
if not %reply%=="who is there?"
(echo "sorry, but you are not playing the game right!" goto:eof)
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
set /p reply="orange d:>"
cls
if not %reply%=="orange who?"
(echo "sorry,but you are not playing the game right!"goto :eof)
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo "orange you glad you've written your first windows shell script?"
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .
echo .

I've dropped it to lower case as the first step to convert to a shell script. Windows isn't case sensitive and bash is. If you save it with a .bat suffix even kwrite will recognise the syntax!

However, it won't run in bash because although some of the basic syntax of batch and bash is similar (especially pipes and redirection), the commands are different.

As pags said, it's not clear what the task is. Are you supposed to install a batch interpreter into Linux? (That could be a reasonable goal as batch is just a primitive shell language, and wine includes a Linux version.) Are you supposed to convert the commands to some GNU shell equivalents? Does the instructor not know the difference? (Oh dear!)


Yes Yes No Yes Yes Maybe.   I am kidding  ;D I had to Google the .bat file for point of reference. It was to show you what the assignment was all about.

No. From I understand the instructor may have confused the assignment, so this is why we were told to forget it and start the next assignment which was using vi editor in the other distro which was already named.

Here is the fun part she got on me for not completing some assignments but when i come in 4 hours early to complete the assignments she task me to help with her other class lol. as this lab is the only place that houses all of software especially Virtual Box.


But Thank You kjpetrie.  You really help alot! and for you all thank you again I will try to get a better Handle on this and I am sorry for wasting any of your time with something so trivial. But you have my deepest gratitude.
UPDATED!! ASUS U52F Notebook i5 CPU,  4Gb ram, 640Gb Hard drive Dual-Boot Win 7Pro/KDE 4 3.2.18-pclos2.bfs

ASUS U50F notebook i3 4Gb Ram. 500 GB hard drive dual-boot Win 7/ KDE 3.2.18-pclos2.pae.bfs    Of course thats just my opinion I could wrong