Terminal-specific characters in password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Terminal-specific characters in password
# 1  
Old 04-03-2008
Terminal-specific characters in password

Good morning!

I am using a shell script to back up user email files to a remote location. The problem is, one (and apparently more than one) users have the symbol "@" in their password. As you can see from the line:

/sbin/mount_smbfs //sampleusername:userpassword@home@XXX.XXX.XXX.XXX/mailshare

( Where their user password is: "userpassword@home" )

This then causes the script to believe that the host server name begins earlier than it really does, which causes the mount to fail.

Aside from the obvious answer of having them change their password (and this is a senior research scientist I'm dealing with, so I'm not keen on starting a big issue with them), is there a way to set off the password?

For example, when you try to copy a folder with spaces in the name, you can set it off with double quotes. Is there any such method for the password?

I have already tried single and double quotes already, to no avail. I also tried, on advice from another, to use the backlash just before the @ character within the password. However, this seemed to set off the entire rest of the line, as that yielded the error:

mount_smbfs: server connection failed: No route to host

You would think it wouldn't be a big deal to just have her change her password.. but such is life when dealing with academia.
# 2  
Old 04-04-2008
I should also add that the double quotes do work in the same script for setting off part of a directory, as in:

ditto -V ~/Library/"Application Support/AddressBook" "/Volumes/Dropbox/BrianW/mac/mail"

But it does not seem to work in a mount command for the password call. Is there any way to set off the password, or must I simply have them change it to remove any 'invalid' characters? Such as @
# 3  
Old 04-04-2008
as i understand, you need to get the ip address out, so that you can connect. you cannot assume things in password, because a password may contain an ip address itself (!!)
i think you need to parse backwards, from right to left, or maybe reverse the string and then get the ip address out using the leftmost match (substr etc.) and then reverse again. sorry cant tell u the commands offhand, maybe u can do some research and if u face issues post with ur code.

good luck!
# 4  
Old 04-04-2008
Quote:
Originally Posted by ag79
as i understand, you need to get the ip address out, so that you can connect. you cannot assume things in password, because a password may contain an ip address itself (!!)
i think you need to parse backwards, from right to left, or maybe reverse the string and then get the ip address out using the leftmost match (substr etc.) and then reverse again. sorry cant tell u the commands offhand, maybe u can do some research and if u face issues post with ur code.

good luck!
I will need that luck, what you're describing is a good deal beyond my range of experience, heh. I'm starting to learn shell programming and scripting from the ground up, essentially. I take it then, that there is no way to simply 'set off' the password?
# 5  
Old 04-05-2008
I seem to recall smbmnt allows you to backslash-escape any @ character in the password itself.
# 6  
Old 04-07-2008
try this..

#!/bin/sh

var='apasswordwith123splchars()/"*&/("*%andthe atsignyouwant@moretext@11.22.33.44'

#Get the total length
varlen=`echo $var | wc -c`
varlen=$((varlen))

ctr=$((varlen-1))

#Parse right to left...
while true
do
if [ $ctr -eq 0 ]
then
# "@" was not found, do error handling here..
break
fi

nthchar=`expr substr "$var" "$ctr" 1`;

if [ "$nthchar" == "@" ]
then
# Found the @ sign
break
fi

ctr=$((ctr-1))

done

iplen=`expr "$varlen" - "$ctr"`

ipaddress=`expr substr "$var" "$ctr" "$varlen"`

echo $ipaddress
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill specific terminal using shell/bash

Hello elite shell/bash specialists, I have done plenty of STFW and some RTFM, but I cannot find a clear solution to my challenge Goal: My goal is to have a script(of any language, preferably shell/bash/anything that can run things on unix), which will kill specific unix terminal windows for... (0 Replies)
Discussion started by: kamil-mech
0 Replies

2. UNIX for Dummies Questions & Answers

Questions About Using Escape characters ('\') In Terminal

I have been looking at people posting commands like : $ sudo apt-get install git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 tofrodos... (2 Replies)
Discussion started by: Ryuinferno
2 Replies

3. Solaris

Manage ILOM password from terminal

Hi, I have T5240/M9000 servers running Solaris 10. I want to manage root password from terminal only using scadm command. Can somebody help me on this? Which package do I need to install and what all configuration need to be done? Thanks, Prashant (1 Reply)
Discussion started by: prashant2507198
1 Replies

4. Shell Programming and Scripting

Count specific characters at specific column positions

Hi all, I need help. I have an input text file (input.txt) like this: 21 GTGCAACACCGTCTTGAGAGG 50 21 GACCGAGACAGAATGAAAATC 73 21 CGGGTCTGTAGTAGCAAACGC 108 21 CGAAAAATGAACCCCTTTATC 220 21 CGTGATCCTGTTGAAGGGTCG 259 Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
Discussion started by: thienxho
2 Replies

5. Shell Programming and Scripting

Can't figure out how to find specific characters in specific columns

I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes. Is there a search for that? I tried cut but couldn't get it to work. Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Discussion started by: Drenhead
12 Replies

6. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

7. Shell Programming and Scripting

Write a message on specific user terminal

Hi All, Need urgent help!!! Can anyone tellme how can we send a message on specific user terminal and get a response from user in return. Thanks in advance. (3 Replies)
Discussion started by: Sadhana
3 Replies

8. OS X (Apple)

Need help writing an Applescript to launch a specific Terminal Command...

I developed a script in Lingon (which is an automated script editor developed for OS X) that is used to automatically restart programs only if they crash. The script itself does just that, but I only want it to load if I'm going to use the specific application that it's designed to protect. In the... (2 Replies)
Discussion started by: JFraser1
2 Replies

9. UNIX for Advanced & Expert Users

password verification verify password of a user for only first 8 characters

Helo , I m using linux pam library for user and its password authentication. I m creating new user and giving its password.I m giving password of 10 characters.now when I login in as that newly created user its ask me $ su - ram Password: You are required to change your password immediately... (12 Replies)
Discussion started by: amitpansuria
12 Replies

10. UNIX for Advanced & Expert Users

Understanding terminal display of (awkward) characters

Gurus, I've been on computers for a while, but I've yet to have the behind-the-scenes knowledge. I'm not sure if this is so much a Unix question as it is a nitty gritty computer one. We received a customer file which had a "funny apostrophe." When displaying the file via more, the character... (1 Reply)
Discussion started by: effigy
1 Replies
Login or Register to Ask a Question