script to override natting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to override natting
# 1  
Old 03-21-2005
script to override natting

hi all ,

iam trying to telnet to a remote system (A) that is 2 routers away ,
the problem is that when i telnet to the system my IP is changed due to natting b/w the 2 networks .
i want to do a remote backup of the system (A) from a server (B), using the following script :

#! /usr/bin/ksh
DELAY=3
PASSWD=passwd
USER=root
exec 4>&1
telnet 192.168.x.xx >&4 2>&4 |&
sleep $DELAY
print -p $USER
sleep $DELAY
print -p $PASSWD
sleep $DELAY
print -p IP=`last -1 |awk '{print $3}'`
print -p sleep $DELAY
print -p ufsdump 0uf $IP:/dev/rmt/1 /
print -p ufsdump 0uf $IP:/dev/rmt/1 /data
print -p ufsdump 0uf $IP:/dev/rmt/1 /data1
wait
print -p exit
wait


but the problem is that when iam doing "IP=`last -1 |awk '{print $3}'`" iam getting my local IP and not the one that is recognized by (A)
that is if i do last -1 on (A) i get something like 192.168.x.x while the value of the script variable IP is 172.16.x.x
iam using solaris 8 (A) , solaris 9 (B) over SPARC.
thanks for ur help.
# 2  
Old 03-21-2005
You're really painted deep into a corner here. With a very different concept in the script, you might be able to do something like:

print -p last -1 |awk '{print $3}'
read -p IP

But it would be very hard (perhaps impossible) to to position everything correctly to get that to work. Switching to expect could work. I would just hard code te return IP address. But you could get this to work using a sequence of 3 ksh co-processes. First telnet in and do:
print -p last -1 |awk '{print $3}' > IPFILE
Then use an ftp co-process to retrieve that file. Read it to get the value for IP. Finally run the third co-process which is a telnet session that does the backup.
# 3  
Old 03-21-2005
Upon further review...

It occurred to me that the IP variable doesn't need to be set in the local shell.
print -p 'ufsdump 0uf $IP:/dev/rmt/1 /'
will cause the remote shell to expand IP. So to set IP, do something like this:
print -p 'IP=`last -1 |awk \'{print $3}\'`'
# 4  
Old 03-22-2005
10x

thanks Perderabo i will try it and post my feedback...
thank u once again .
# 5  
Old 03-22-2005
got error

sorry it is not happy yet, i got the following error .

syntax error at line 20 : ``' unmatched

i have never used "expect scripting " is it easier to implement it in my case .
cause really i think that iam way over my head , i have treid everything i know and it is still not working .
# 6  
Old 03-22-2005
Cut and paste the line that is causing you trouble. This is a simple quoting problem.
# 7  
Old 03-22-2005
i have used what u posted : print -p 'IP=`last -1 |awk \'{print $3}\'`' and it gave me the above error .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to override Classpath?

Hi, When I login to my HP-UX and fire the "set" command I see that the weblogic 9.2 classpath is already set. However, I wish to override the classpath to weblogic version 10.3 I have a script call setWLSEnv.sh that has the desired classpath. Thus, in my unix script i write .... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. UNIX for Dummies Questions & Answers

Override options of rm command

How can i override options of rm command ?? and how can i implement my own options when we delete file using rm commad it will not delete file it has to move some folder....plz suggest some solution. (10 Replies)
Discussion started by: arun508.gatike
10 Replies

3. Shell Programming and Scripting

override protection 644 (yes/no)?

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (9 Replies)
Discussion started by: sri_aue
9 Replies

4. UNIX for Dummies Questions & Answers

Can you override root shell?

Hi, I'm trying to figure out the logic of my user shell and root shell :confused: This might be best illustrated with an example. If I log into the linux host I'm using and run the following: -bash-3.2$ which python /usr/local/bin/python I now run sudo bash to become root and run the... (2 Replies)
Discussion started by: cuchulainn
2 Replies

5. Shell Programming and Scripting

can getopts be used to override user input in a script

I have a script which takes user input as options provided PS3="Select option to do deploy : " select OPTION in "eardeploy" "hotdeploy" do case $OPTION in "eardeploy" ) eardeploy.sh break;; "hotdeploy" ) ... (1 Reply)
Discussion started by: codeman007
1 Replies

6. Programming

How to override my profile

I would like to override the default profile which is loaded when the system starts or When I run a program so that profile should get loaded in the settings. Is there any system call to do so. . (0 Replies)
Discussion started by: mobile01
0 Replies

7. Programming

override the function in C

hi , greetings , I have one doubt reg the C functions . I have a program sample.c , in which i have function name scanf , which reads a a variable and prints the variable inside the function . this scanf is nothing to do with C library function scanf , but i would like to use only user... (1 Reply)
Discussion started by: naren_chella
1 Replies

8. AIX

date override

When the aix date function is called by a routine, is the date function 'aware' of the name of the routine that is calling it, such that if we had the source code of the date function, we could modify it so that it provides a date to the caller depending upon the identity of the calling routine.... (1 Reply)
Discussion started by: gerry shacter
1 Replies

9. IP Networking

Override

Hi My computer of late started misbehaving. Whenever I switch it on It say Override and then it takes long to boot. Surprising is that it opens excel automatic. What could be that? (1 Reply)
Discussion started by: Mulo
1 Replies

10. UNIX for Dummies Questions & Answers

Override protection.....

I am having this problem......when I run this script: print -n "Enter file name to be deleted: " read answer if then rm $name else echo "No such file with the name: $name exists" fi I was trying to test my script for errors, and basically when the user had files with the rights: 400,... (1 Reply)
Discussion started by: Makaveli.2003
1 Replies
Login or Register to Ask a Question