Windows Batch to Unix Shell script
I needed to make a windows batch file for school. I made an alarm clock that opens windows media player and plays a file and closes it after the file has finished playing. Now I need to make the same thing but in Shell script. I know nothing about Unix Shell script. Can someone please help me to convert this batch file to a shell script?
The Batch file looks like this: CLS @echo off color f0 title Batch Alarm Clock echo. echo. echo Use 24-hour clock echo. echo. set /p a=Set alarm: CLS echo. echo. echo Alarm has set to %a%. :alarm if %time:~0,5% EQU %a% goto alarmset goto alarm :alarmset start wmplayer /play /close "c:\Users\Andreas\Music\alarm.mp3" # TIMEOUT is the duration of the song and after that the taskkill closes windows media player TIMEOUT /T 231 taskkill /im wmplayer.exe |
Quote:
Best suggestion I could make, is to walk through the file one line at a time, and identify what each command does, and figure out what the equivalent Linux command is. For example, "CLS" is "clear". Have you tried to look at any of the easily-found bash scripting tutorials? http://tldp.org/LDP/abs/html/ |
This is what I have done so far:
clear set +v color f0 Don't know how to change the color, but it isn't important anyway title Batch Alarm Clock The title isn't important either echo echo echo Use 24-hour clock echo echo export /p a=Set alarm: Replaced "set" with "export" but don't know how to replace the command " /p a=Set alarm: " clear echo echo echo Alarm has set to %a%. " %a% " is another part that I don't know how to convert And I don't know how to convert this part from here to the end. if %time:~0,5% EQU %a% goto alarmset goto alarm :alarmset start wmplayer /play /close "c:\Users\Andreas\Music\alarm.mp3" TIMEOUT /T 231 taskkill /im wmplayer.exe |
Quote:
http://kedar.nitty-witty.com/blog/ho...n-shell-script Quote:
|
Ok, thank you, I try to continue converting it when I get back home. I don't remember what the " /p " command did.
|
The guide TB0ne linked to even has a whole page specifically on converting batch files to shell scripts.
http://tldp.org/LDP/abs/html/dosbatch.html Also, please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting. |
See also http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html as well as TB0ne's link
|
Batch to Shell script
Hi, I'm trying to translate a batch file to shell script but I'm a little stuck with this command:
echo cd /home/opera/SCRIPTS/medios>>tempo echo pwd>>tempo echo lcd ../tesoreria>>tempo echo prompt>>tempo echo mget *.pag>>tempo echo mdel *.pag>>tempo I don't underestand what lcd, mget and mdel commands do here. Thak you |
Quote:
Does that make sense to you? |
I don't have lcd or mget, but mdel according to the man page is for deleting MSDOS directories recursively.
|
Quote:
|
Quote:
so to break down what is happening, ftp to "opera's" computer ( not detailed in the snippet with have )
anyway, to translate that to Linux, first need to decide on which ftp client, and then learn its commands and scripting format |
All times are GMT -5. The time now is 05:37 AM. |