LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 05-27-2010, 02:29 PM   #1
asterix1
LQ Newbie
 
Registered: May 2010
Posts: 2

Rep: Reputation: 0
Smile $ interpretation problem and question about ls


Hi!

I) I wrote a programm which validates a password given to it as the first argument. The password must be of minimal length 8, it must contain at least 2 numerical and two non-alphanumerical characters.
The problem occurs when i want to include two $ signs in the password, for example...password : validate_password.sh abc$$123.

Echo or printf return: abc4534123.The dollar signs are changed. I found out that if i put the password in single quotes it works fine.
The problem is, that i dont want it to be in single quotes.

Is there a switch for disabling the interpretation of the $ sign?

II) I wrote a program that prints out the latest modified file. I used "ls -lrt". My question is...can i somehow give ls a specific directory (for example: /user/etc)so ls will (recursively)list only its content?
The directory would be given to the program as the first argument.
See below for an idea of what i mean...

directory=${1}

ls -lrt ${1} ...do stuff only for the files returned by ls.
 
Old 05-27-2010, 03:03 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by asterix1 View Post
Hi!

I) I wrote a programm which validates a password given to it as the first argument. The password must be of minimal length 8, it must contain at least 2 numerical and two non-alphanumerical characters.
The problem occurs when i want to include two $ signs in the password, for example...password : validate_password.sh abc$$123.

Echo or printf return: abc4534123.The dollar signs are changed. I found out that if i put the password in single quotes it works fine.
The problem is, that i dont want it to be in single quotes.

Is there a switch for disabling the interpretation of the $ sign?
No but there is almost certainly a way to do what you want. When you write "i dont want it to be in single quotes", where don't you want it to be in single quotes? On the command line to your script? If you want the shell to ignore $ there then you must either put it in single quotes or "escape" it like abc\$\$123
 
Old 05-27-2010, 03:05 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by asterix1 View Post
II) I wrote a program that prints out the latest modified file. I used "ls -lrt". My question is...can i somehow give ls a specific directory (for example: /user/etc)so ls will (recursively)list only its content?
The directory would be given to the program as the first argument.
See below for an idea of what i mean...

directory=${1}

ls -lrt ${1} ...do stuff only for the files returned by ls.
Better to ask only one question per thread -- it gets confusing when two questions are answered in the same thread.
 
Old 05-28-2010, 12:20 AM   #4
asterix1
LQ Newbie
 
Registered: May 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Hi!

Yes, i dont want to put my password in single quotes in the terminal, when i call the program, because the program is written for a user, who would not know, that he/she must put his password in single quotes. So the user would simply type ....validate_password.sh abc$$$123 ,without the password being in quotes.
 
  


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
netstat interpretation twlilinux Linux - Server 6 06-17-2008 04:59 PM
Interpretation of KDE Crash ? orbit Slackware 0 04-02-2008 09:32 PM
c: output interpretation kpachopoulos Programming 3 08-17-2006 09:34 AM
tcpdump interpretation unixbrain Linux - Networking 7 04-28-2004 04:37 AM
2.4.18 Crash interpretation: Known problem? svar Linux - General 2 09-17-2003 12:42 AM

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

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