Showing posts with label Remote. Show all posts
Showing posts with label Remote. Show all posts

Tuesday, 29 October 2013

Copy using Scp in shell script using expect !!

Here is simple script to copy using scp and expect ,
We are creating a simple script on the fly and run that script

cat > /tmp/copy_from_remote.sh << EOF
#!/usr/bin/expect
set timeout 10
log_user 0
spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $REMOTE_CREDENTIAL_USERNAME@$host_name :$

expect "*?assword"
send "$CREDENTIAL_PASSWORD\r"
expect "*100\%*\r"
EOF

chmod 777 /tmp/copy_from_remote.sh
sh /tmp/copy_from_remote.sh

Once script is ready need to run .
 For details we can add exp_internal 1 in the expect script
 Need to disable host key checking and known host file .



Tuesday, 22 January 2013

Simple but useful


1)  Share your files and folders residing on your Linux machine with anyone across the web.



Here is the simple way to share files across network on linux , without the need of SMB or NFS .

Open a bash terminal and create an alias as follows:

Next navigate to the directory which you want to share with someone and run  $ python -c "import SimpleHTTPServer;SimpleHTTPServer.test()" command

Your Linux machine will now start serving the whole directory tree on the port number 8000.
And anybody can access all your files within that directory at the following web address – http://:8000/.

Tip:
If you have firewall enabled , you need to open port 8000.

2) Open xwindow apps on remote system:

only local , open a Linux window and type the following:
  • xhost +
  • telnet
  • setenv DISPLAY :0.0
  •      &

Application will open yr local system .


3) Find Out The Top 10 Memory Consuming Process
# ps -auxf | sort -nr -k 4 | head -10
4) Find Out top 10 CPU Consuming Process
# ps -auxf | sort -nr -k 3 | head -10
5) iostat  : average cpu activity
6) pmap -d PID  : memory map of a process
7) copy directory to remote linux 
      scp -r @ :remote .