LinuxQuestions.org
Visit Jeremy's Blog.
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 09-11-2011, 05:29 AM   #1
markcoker
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
Bash Scripting (BT5-R1) - not a valid identifier & \r': No such file or directory


Hello, i feel this should be easy problem to fix, ive just hit a brick wall. This is my first bunch of scripts. What they are is a menu for automation of wireless cracking and cleanup script. The rest work fine so im now confused why im having so much trouble with the *easy* parts. I am running these scripts on Back Trace 5 - R1 let me know if you need any other information

menu.sh
-------
green="\e[1;92m"

echo -e $green

echo "*********************************************"

echo "* Mark's Wireless Access Point Cracker *"

echo "*********************************************"

echo "* a) Brute-Force Wireless AP *"

echo "* b) Update Wordlist (newlist>biglist) *"

echo "* c) Clean-Up (removes dump & Backup files) *"

echo "* d) Exit *"

echo "*********************************************"

read -p "Please pick an option. " ABCD

echo $ABCD

Error
------
': not a valid identifier `ABCD

Strange, Ive used read -p in my main script & it worked. I've tried different variables, lowercase / uppercase. ive also tried with "" around variable name. This error occurs once a value is entered in terminal. Im stuck

cleanup.sh
----------
green="\e[1;92m"

echo -e $green"Clearing Old Data...."

rm /media/8GB/wl_tools/wordlist/*.bak

rm /media/8GB/wl_tools/wordlist/newlist_sort

rm -r /media/8GB/wl_tools/dump/*

echo "Complete!"

Error
------

rm: cannot remove `/media/8GB/wl_tools/wordlist/*.bak\r': No such file or directory
rm: cannot remove `/media/8GB/wl_tools/wordlist/newlist_sort\r': No such file or directory
rm: cannot remove `/media/8GB/wl_tools/dump/*\r': No such file or directory

This error occurs when running in terminal, if i run these commands manually in terminal works perfectly. seems to \r to the end of the directory i have no idea why or what it means, but it seems to be the reason why it is failing.

Thanks for your help.
ps. These are my first bunch of scripts so any other tips great appreciated too
 
Old 09-11-2011, 05:38 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The \r is the shortcut for carriage-return. It is a line terminator usually appended by windows systems, that is a line of text in windows terminates with \r\n whereas on Unix machines it ends with a single \n. Maybe you've written the scripts on a windows machine? If this is the case, try to run the dos2unix command on the script before running them again: it should convert the line terminators to the unix style.
 
1 members found this post helpful.
Old 09-11-2011, 06:08 AM   #3
markcoker
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Exclamation

Quote:
Originally Posted by colucix View Post
The \r is the shortcut for carriage-return. It is a line terminator usually appended by windows systems, that is a line of text in windows terminates with \r\n whereas on Unix machines it ends with a single \n. Maybe you've written the scripts on a windows machine? If this is the case, try to run the dos2unix command on the script before running them again: it should convert the line terminators to the unix style.
OF COURSE! thanks so much, i restart computer after making main script and made the rest! haha idot! thanks
i converted, and all is fine! works perfectly
 
  


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
Bash Scripting: Redirect output of entire script to file & screen Kristijan Programming 3 10-12-2017 03:17 PM
Not A Valid Identifier jetsons Linux - Software 1 01-04-2011 01:28 PM
Going through files in a directory, bash scripting Pewgs Linux - Newbie 10 04-11-2010 11:34 PM
BASH Script --> read a file & cp -r to my ~/ directory manwithaplan Linux - Newbie 6 10-05-2009 11:25 PM
BASH scripting: confused about redirection & file descriptors funkymunky Programming 1 06-07-2004 07:47 AM

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

All times are GMT -5. The time now is 11:32 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