LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2013, 07:57 PM   #1
FlexBuffChest92
Member
 
Registered: Mar 2012
Location: US
Distribution: Ubuntu 11.10, SLAX 6.1.2, CrunchBang 11, BackTrack 5,
Posts: 93

Rep: Reputation: Disabled
Help with my script???


I have decide to take on the task of learning Assembly programming and while bored one night I decided to write a little script to help compile and build my Assembly source files. What I am asking of you fine folks is to help me out, show me what I have done wrong, what i could improve and maybe some new ideas for the script?

Here is my script
Code:
#!/bin/bash
#: Title	:asm2exe (Assembly to Executable)
#: Date		:(C)2013
#: Author	:lancelot
#: Version	:1.0
#: Description :A small script to compile and build .asm files with ease.
#: Options	:


#!/bin/bash
echo "            _____ __  __ ___  ________   ________ 
     /\    / ____|  \/  |__ \|  ____\ \ / /  ____|
    /  \  | (___ | \  / |  ) | |__   \ V /| |__   
   / /\ \  \___ \| |\/| | / /|  __|   > < |  __|  
  / ____ \ ____) | |  | |/ /_| |____ / . \| |____ 
 /_/    \_\_____/|_|  |_|____|______/_/ \_\______|" #display ascii art logo
 echo	#skip a line
 echo	#skip a line
 echo "This is a program to make compiling"
 echo " and building your .asm files a breeze!\c"	#display message to user
 echo 	#skip a line
 echo "Enter the name of the file you would like to compile"
 echo "(Please use the full path if it applies):" #prompt user to enter filename
 read filename	#read input and save it in filename
 echo "You want to compile $filename, correct? (y/n)" #prompt user again to be sure
 read answer
 if test "$answer" = y
 then 
	echo	#skip a line
	echo "Compilation will begin shortly..."	#display message to user
	nasm -f elf $filename 	#begin building process
	echo "Ready to begin with step 2!"
	echo "Please enter the new file name"	#prompt user for .o file
	read file2
	echo "\n"
	echo "Finalizing compilation..."
	gcc $file2 -o final
	
else
	echo "Please re-enter the name of the file you would like to use: "	#prompt user to re-enter initial file name
	read filename	#re-check user input
fi
echo "Your file is ready!"
echo "Thank you for using asm2exe"
exit 0
 
Old 11-01-2013, 04:23 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
@FlexBuffChest92: The above script needs some work.

I noticed these mistakes:
- #!/bin/bash is used twice. There should be one, and it should be the first line of your script).
- There's an unwanted \c in this line: echo " and building your .asm files a breeze!\c"
- There's an unwanted \n in this line: echo "\n"

The above mentioned mistakes won't interfere with the functionality of the script, but I also noticed the following:
- The script doesn't check if a file name is given (empty input).
- You also might want to check if the file name given is correct.
- If the user answers no to the "You want to compile $filename, correct? (y/n)" question, it askes for a new name and then does nothing (no loop).
- There's no error checking for both nasm and gcc commands.

I haven't looked at the validity of the nasm and gcc commands, I'm assuming they are syntactically correct.

Have fun implementing the above suggestions and if you get stuck: Just ask.
 
  


Reply



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
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 10 07-17-2012 09:36 AM
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 1 07-13-2012 01:03 AM
Shell script, Perl script, command or utility to convert Binary to text Perseus Programming 26 07-12-2012 06:00 AM
[SOLVED] bash and xterm: how make apps started by and for a script persist when script terminates porphyry5 Linux - General 4 06-15-2011 01:27 PM
[SOLVED] Script question: create a shell script in kde to log in on a server with ssh c4719929 Linux - Newbie 1 01-31-2011 03:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:42 PM.

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
Open Source Consulting | Domain Registration