Visit The New, Modern Unix Linux Community


netstat command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting netstat command
# 1  
netstat command

Hi,

In my project we use sftp with batch mode (password less) script in parallel for 14 sessions which connects to 2 different servers alternatively i.e. 7 connects to one server say server1 and the other 7 connects to say server 2.

Now the problem is that these 14 sessions are run in parallel then only 2 or 3 of them get succeeded while the rest runs for a very long time like 2 hours and then gets timed out. The unix admins told that sftp script is not closing the connection gracefully.

The command which I use in the sftp script is

Code:
sftp -b <batch file> user@ftp_address

They told me to check if the connections are closed or not can be checked by command. So I executed the below command even when the sessions were not running.

Code:
netstat -an | grep <IP address of the GUI tool which calls the script>

This shows something like below:

Code:
tcp        0      0 ::ffff:XXX.XX.XXX.XX:XX    ::ffff:YY.YYY.YY.YYY:ZZZZ   ESTABLISHED
tcp        0      0 ::ffff:XXX.XX.XXX.XX:XX    ::ffff:YY.YYY.YY.YYY:MMMM  ESTABLISHED

And seeing the above "ESTABLISHED" o/p they are claiming that my script is not closing the FTP connection!! I'm really confused as to how to close the SFTP connection when using it in batch mode there is no explicit command like "bye" with password-less sftp. Can anybody please help me understand that if the unix admins are right in their claim that really my script doesn't close the connection automatically and if yes then how to close it?

-dips

Last edited by pludi; 11-08-2011 at 09:39 AM..
# 2  
Did you not put a quit at the end of your batch script?
# 3  
Quote:
Originally Posted by vbe
Did you not put a quit at the end of your batch script?
"quit" as in after each time I call sftp -b <batchfile> user@ftp_address command? OR the end line in the unix script?

-dips
# 4  
You should have one in <batchfile>
This User Gave Thanks to vbe For This Post:
# 5  
Hi vbe,

Sorry I couldn't reply earlier. But I really want to thank you as your solution worked and now the 14 parallel sessions accessing the same FTP connection alternatively is working fine. SmilieSmilieSmilie

There's one more thing I wanted to ask you, that is if you can spare some more time, is that after running the scripts with "quit" command in the batchfile now my earlier scripts (w/o "quit") are also working fine!! Smilie

Can that be because contention of the connections got solved with the "quit" cmd? And the "parallel thing" will work until the Max Connection limit to FTP site is met?

-dips

P.S. I apologize for the subject of my post being non-descriptive. I'll surely remember that in future.
# 6  
UNIX servers usually have default network TIMEOUT set to values that were from the times of 10Mb networks... In other words the times when you could unplug and move around cables without taking too much risks of seeing the server crashing (complaining at the most) then came interconnection with WIN.. serversin multi-tier environment and users on PCs with 100Mb/1GB lan interfaces and things changed a bit: admins started to have strange issues where people couldn't connect anymore, application were no more responding... due to no more sockets etc... because e.g for the case of PCs, when no more activity for a little time the PC closed the connection and when activity started again -opened a new one... On the UNIX side though the connection did not get the close request and stayed in a zombiesque state till the server cleared the TIMEOUTs. We were talking of second on one side and minutes on the other...
So your understanding is correct...
It shows that things you write that work may still be buggy... And needs to be tested thoroughly and be sure of the correctness of code (you open an ftp session - you closed it behind...) for even if the code is perfect the usage of it may have side effects:
Now you code is correct. What will happen if you send hundreds of parallel sessions with big transfer? We had one case where all the switches dropped in cascade...

Have a good day
This User Gave Thanks to vbe For This Post:

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #446
Difficulty: Medium
The Large Hadron Collider experiments at CERN run on Scientific Linux.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Filtering netstat command output

Hi All, I am trying to collect the listen ports info from netstat command in centos 7 From that info i am trying to collect all the foreign address IP for those ports. I am using below script to do the same. netstat -an |grep -w "LISTEN" |grep -v "127.0.0.1" |awk '{print $4}' >... (3 Replies)
Discussion started by: sravani25
3 Replies

2. UNIX for Advanced & Expert Users

Regex to match Exact port number (netstat command)

Hi All, We have this regex:\\*.*?(.600).*?.(LISTEN|ESTABLISHED) OS = Solaris 10 The purpose of this regex is to match the ports in output of "netstat -an" and report if any ports between 6000-6009 are getting used. The only problem is if I have something like this (sample output as... (6 Replies)
Discussion started by: sk2code
6 Replies

3. Shell Programming and Scripting

Help with netstat traffic server command

Help required for creating a unix shell script using netstat command for retrieving total traffic in Kbytes with the source and destination address. (4 Replies)
Discussion started by: Samee
4 Replies

4. Shell Programming and Scripting

netstat command to be executed for list of hosts

Hi All, Need to run the netstat -i command on the list of hosts and check if "Ierrs" and "Oerrs" has value greaterthan 0. for Ex: below output, driver bge1 and bge3 has Oerrs and Ierrs value > 0, So, script should report saying "Netstat status for $host, driver bge1 has Oerrs = 20, Failed"... (5 Replies)
Discussion started by: Optimus81
5 Replies

5. Red Hat

netstat

Hi Can any body tell me about TIME_WAIT status meaning in the following command output. # netstat -anp|grep 5000 tcp 0 0 127.0.0.1:50006 0.0.0.0:* LISTEN 5058/ccsd tcp 0 0 0.0.0.0:50008 0.0.0.0:* ... (3 Replies)
Discussion started by: mastansaheb
3 Replies

6. UNIX for Dummies Questions & Answers

Need help with a netstat command

Do I have this command correct to show all current connections/sessions my Solaris box has? It does not seem to do anything. netstat -an | grep EST (6 Replies)
Discussion started by: SIFT3R
6 Replies

7. UNIX for Dummies Questions & Answers

Netstat command query

hy guys, I did netstat and it is listening, what can i do from the client side that to see if the port is open? Regards Charneet (1 Reply)
Discussion started by: charneet
1 Replies

8. UNIX for Advanced & Expert Users

Netstat command

Hi.., Now, I am reading about the netstat command and its implementation. I have doubts in some options and its functionalities, natstat - M (Which is described as display masqueraded connections), what it means? What is Forwarding Information Base.?(--fib) Thanks in advance,... (3 Replies)
Discussion started by: nagalenoj
3 Replies

9. IP Networking

netstat

Hi what is the command to see the process name/application name along with the port number, connection status ... netstat is not giving process/application name Is there any way to know which application is holding which port? Thanks in advance (3 Replies)
Discussion started by: axes
3 Replies

10. UNIX for Dummies Questions & Answers

netstat command between clustered hosts

I have 2 clustered hosts, is it possible for me to issue a netstat command against 1 host from the other ? (4 Replies)
Discussion started by: murphyboy
4 Replies

Featured Tech Videos