- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Can someone explain this...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:02 AM
02-06-2004 07:02 AM
IPLIST=/the/correct/path/sw_ip.txt
for IP in $(cat $IPLIST)
do
echo $IP
echo $IP
echo "$IP"
echo $IP ","
echo "$IP ,"
echo "$IP, changed passwd."
echo "$IP changed passwd."
echo $IP", changed passwd."
done
Output:
123.456.20.50
123.456.20.50
123.456.20.50
,3.456.20.50
,3.456.20.50
, changed passwd.
changed passwd.
, changed passwd.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:10 AM
02-06-2004 07:10 AM
Re: Can someone explain this...
To get the behavior you expect use the form ${IP} and it will work much better.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:13 AM
02-06-2004 07:13 AM
Re: Can someone explain this...
for IP in $(cat $IPLIST)
do
echo ${IP}
echo ${IP}
echo "${IP}"
echo ${IP} ","
echo "${IP} ,"
echo "${IP}, changed passwd."
echo "${IP} changed passwd."
echo ${IP}", changed passwd."
done
123.456.20.50
123.456.20.50
123.456.20.50
,3.456.20.50
,3.456.20.50
, changed passwd.
changed passwd.
, changed passwd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:14 AM
02-06-2004 07:14 AM
SolutionI cut and pasted your shell script and I tried it on one of my 11i boxes. It seems to work correctly:
>./ip_test.sh
123.456.20.50
123.456.20.50
123.456.20.50
123.456.20.50 ,
123.456.20.50 ,
123.456.20.50, changed passwd.
123.456.20.50 changed passwd.
123.456.20.50, changed passwd.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:15 AM
02-06-2004 07:15 AM
Re: Can someone explain this...
#!/usr/bin/sh
IP=123.45.67.89
echo ${IP}
echo "${IP}"
echo ${IP} ","
echo "${IP} ,"
echo "${IP}, changed passwd."
echo "${IP} changed passwd"
echo ${IP}", changed passwd"
OUTPUT:
123.45.67.89
123.45.67.89
123.45.67.89 ,
123.45.67.89 ,
123.45.67.89, changed passwd.
123.45.67.89 changed passwd
123.45.67.89, changed passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:18 AM
02-06-2004 07:18 AM
Re: Can someone explain this...
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=426931
I have no idea why your shell is behaving like this. You should have gotten atleast from echo "$IP changed passwd." withouth using {} around the variable.
Can you try it in another window?. Add #!/usr/bin/ksh to the starting of the script and see if it makes any difference.
#!/usr/bin/ksh
IPLIST=/the/correct/path/sw_ip.txt
for IP in $(cat $IPLIST)
do
echo $IP
echo $IP
echo "$IP"
...
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 07:21 AM
02-06-2004 07:21 AM
Re: Can someone explain this...
I just tried the following with no problem:
Script:
#!/usr/bin/sh
IPLIST=iplist
for IP in $(cat $IPLIST)
do
echo ${IP}
echo "${IP}"
echo ${IP} ","
echo "${IP} ,"
echo "${IP}, changed passwd."
echo "${IP} changed passwd"
echo ${IP}", changed passwd"
done
iplist file:
# cat iplist
12.34.56.78
90.12.34.56
OUTPUT:
12.34.56.78
12.34.56.78
12.34.56.78 ,
12.34.56.78 ,
12.34.56.78, changed passwd.
12.34.56.78 changed passwd
12.34.56.78, changed passwd
90.12.34.56
90.12.34.56
90.12.34.56 ,
90.12.34.56 ,
90.12.34.56, changed passwd.
90.12.34.56 changed passwd
90.12.34.56, changed passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 09:02 AM
02-06-2004 09:02 AM
Re: Can someone explain this...
Had no idea that the file was created in notepad...
Had to dos2ux!
Works fine now!
THanks for all your help!
I know everyone has spent alot of time on it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 09:32 AM
02-06-2004 09:32 AM
Re: Can someone explain this...
The \r causes a carriage return thus over writing the first part of the data.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2004 01:32 PM
02-06-2004 01:32 PM
Re: Can someone explain this...
cat -v some_file
xd -xc some_file
Bill Hassell, sysadmin