-->
🏠 🔍
SHAREOLITE

SOLVED : DBI DBD ORA-24365: error in character conversion

In one of our Linux based web servers using Oracle 11g database and DBI DBD perl modules , we observed a peculiar error where on accessing a web page , below error was reported




Error Observed :
 
ORA-24365: error in character conversion
The character set used and the function calls were proper.
 
Solution :
  
After lot of searching , few possible reasons for this error was found to be , when using DBI & DBD modules for Oracle - if ORACLE_HOME environment is not set in the webserver configuration , then those library functions may return this error.
  • In our case we used Apache HTTPD web server, so we added our DB install directory in httpd.conf configuration file.
  • SetEnv ORACLE_HOME "/u01/product/db_1"
  • Restarted the web services , after which error was not observed.
Hope this helps to some.

SOLVED : PLS-00201 , PLS-00221: 'DBMS_LOCK' is not a procedure or is undefined

In an application using Oracle database DBMS_LOCK procedure  , sometimes if the grant permissions are not provided it may result in below errors
 

 


Error observed  : PLS-00201

PLS-00201: identifier 'SYS.DBMS_LOCK' must be declared

Solution :

Reason : DBMS Lock package is not declared 

  • Login to DB schema
  • Execute the oracle default procedure $ORACLE_HOME/rdbms/admin/dbmslock.sql
  • @$ORACLE_HOME/rdbms/admin/dbmslock.sql


Error observed  : PLS-00221

SQL> exec DBMS_LOCK();
BEGIN DBMS_LOCK(); END;

      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'DBMS_LOCK' is not a procedure or is undefined
ORA-06550: line 1, column 7:

PL/SQL: Statement ignored

Solution :

Reason : Schema user may not be having permission to use DBMS Lock package
  • Login to DB schema
  • Execute the grant query to provide permission access to DBMS lock package
  • Syntax : GRANT EXECUTE on dbms_lock to <dbuser>;
  • Example :  GRANT EXECUTE on dbms_lock to shareolite;

Hope it helps to some beginners.

Linux cronjobs practical examples

A cronjob is a linux scheduler utility which is part of “crond” linux service daemon used to schedule execution of  configured  tasks. There are two methods to configure the task & time of execution


  • Using the system cronjob file edit command with option –e i.e, “crontab –e
  • Using a flat file in which the list of tasks and time of execution are saved and passed as argument to the cronjob comand i.e “crontab <filename>

Syntax of a cronjob entry in a cronjob configuration file

<minute> <hour> <day of month> <month> <day of week>  <command to execute>

Field
Allowed Values
Minute
0 to 59
Hour
0 to 23
Day of Month
1 to 31
Month
1 to 12 or Names first 3 characters i.e, Jan , Feb .. Dec allowed
Day of Week
0 to 7   or Names first 3 characters i.e, Sun , Mon .. Sat allowed


Fields support value ranges , lists and step values as shown in below examples

Cronjob schedule value samples
Description
5 0 * * *
Run at 5th minute after midnight
15 14 1 * *
Run at 14:15 hrs on the 1st of every month
0 22 * * 1-5
Run at 10 PM on weekdays
5 4 * * sun
Run at 4.05 AM every Sunday
30 02 10 1,2,3 *
Run on Jan,Feb,Mar 10th at 02.30 AM
*/5 * * * *
Run every 5 minutes
0 * * * *
Run once a hour at the beginning of the hour
* * * * *
Run every minute
Verify the contents of cronjob file . Below file has 2 tasks configured

$ cat /opt/shareolite/cronjobs
*/2 * * * * sh Shareolite.sh 2>&1
00 02 * * * sh /opt/shareolite/2.sh >> /opt/shareolite.log 2>&1

Initialize cronjob file using the below command
$ crontab /opt/shareolite/cronjobs

Check the cronjob status by executing below command
$ crontab -l
*/2 * * * * sh Shareolite.sh 2>&1
00 02 * * * sh /opt/shareolite/2.sh >> /opt/shareolite.log 2>&1

Remove the cronjob by executing below command
$ crontab –r

For a linux user , only one cronjob can be initialised. Tasks requiring root user privileges are usually configured under root user. On OS reboot , tasks are reinitialised automatically and manual initialisation is not required.


SQL useful select query examples



 
SQL select query example to convert rows to column :

select sum(case when EMP_ID=1 then 1 else 0 END) "Pantry" ,sum (case when EMP_ID=2 then 1 else 0 END) "Security"  from EMP_TABLE where to_char(JOIN_DATE,'DD-MM-YY')='10-11-12';

SQL select case query example :

select case when EMP_ID=1 then 'Pantry' when EMP_ID in (2,3) then 'Security' END  from EMP_TABLE where to_char(JOIN_DATE,'DD-MM-YY')='10-11-12';

SQL select statement example comma seperated delimiter display 

select EMP_ID||','||JOIN_DATE from EMP_TABLE;

SQL select statement example to combine data from two different tables

select * from EMP_TABLE_1 union all select * from EMP_TABLE_2;
 

VMware NIC port View Down Up command line - How to - SOLVED

In this post , we cover a practically working command line option in VMware esxi on how to View VM host server NIC port status , enable or disable it.


Command to view the network NIC ports list

/bin # esxcli network  nic list
Name    PCI Device     Driver     Link  Speed  Duplex  MAC Address         MTU  Description
------  -------------  ---------  ----  -----  ------  -----------------  ----  -------------------------------------------------
vmnic0  0000:006:00.0  igb        Up     1000  Full    1c:a1:82:18:7c:31  1500  Intel Corporation I350 Gigabit Network Connection
vmnic1  0000:006:00.1  igb        Up     1000  Full    1c:a1:82:18:7c:12  1500  Intel Corporation I350 Gigabit Network Connection
vmnic2  0000:006:00.2  igb        Down      0  Half    1c:a1:82:18:7c:22  1500  Intel Corporation I350 Gigabit Network Connection
vmnic3  0000:006:00.3  igb        Down      0  Half    1c:a1:82:18:7c:75  1500  Intel Corporation I350 Gigabit Network Connection
vusb0   Pseudo         cdc_ether  Up       10  Half    1e:a1:81:31:1c:71  1500  Unknown Unknown


Command to view the details of a specific port

/bin # esxcli network  nic get -n vmnic0
   Advertised Auto Negotiation: true
   Advertised Link Modes: 10baseT/Half, 10baseT/Full, 100baseT/Half, 100baseT/Full, 1000baseT/Full
   Auto Negotiation: true
   Cable Type: Twisted Pair
   Current Message Level: 7
   Driver Info:
         Bus Info: 0000:06:00.0
         Driver: igb
         Firmware Version: 1.61, 0x8000090e
         Version: 5.0.5.1
   Link Detected: true
   Link Status: Up
   Name: vmnic0
   PHYAddress: 1
   Pause Autonegotiate: true
   Pause RX: false
   Pause TX: false
   Supported Ports: TP
   Supports Auto Negotiation: true
   Supports Pause: true
   Supports Wakeon: true
   Transceiver: internal
   Wakeon: MagicPacket(tm)

Command to bring down a specific network interface

/bin # esxcli network  nic  down  -n vmnic3

Command to bring back a specific network interface

/bin # esxcli network  nic  up -n vmnic3

Hope this is useful to some VMware command geeks.
 

Cisco switch capture packet trace - Howto - SOLVED

In this post , we present practically verified and working - Cisco switch command line option for capturing packet traces for a specific interface port , which may be analyzed using Wireshark.


Enabling and capturing trace on a cisco switch includes below points.

  • Defining an access list to restrict any specific hosts .
  • Defining a capture trace buffer
  • Attaching an access list filter to this trace buffer
  • Defining any specific interfaces for capture
  • Start the capture 
  • Stop the capture and download the pcap file for analysis
Command line for the above are as below -

Creating an Access list

SW1# config terminal

SW1(config)#ip  access-list  standard acl1
SW1(config-std-nacl)#permit any
SW1(config-std-nacl)#exit
SW1#

Defining a trace capture buffer

SW1#monitor capture trace1 buffer size 1

Attaching an access list filter to this trace buffer

SW1#monitor capture trace1 access-list acl1


Defining any specific interfaces for capture

SW1#monitor capture trace1 interface GigabitEthernet 1/0/2 both

Start the capture for a duration and stop 

SW1#monitor capture trace1 start
SW1#
SW1#monitor capture trace1 stop


Viewing the captured file details


SW1#show monitor capture trace1 buffer brief
  0.000000   1.1.1.2 -> 224.0.0.5    OSPF Hello Packet
  0.376979   1.1.1.2 -> 224.0.0.18   VRRP Announcement (v2)
  1.214985   1.1.1.2 -> 224.0.0.2    HSRP Hello (state Active)

View the capture rules & parameters

SW1#show monitor capture  trace1 parameter
   monitor capture trace1 interface GigabitEthernet1/0/2 both
   monitor capture trace1 access-list acl1
   monitor capture trace1 buffer size 1

SW1#show monitor capture  trace1

Status Information for Capture trace1
  Target Type:
   Interface: GigabitEthernet1/0/2, Direction: both
   Status : Inactive
  Filter Details:
   Access-list: acl1
  Buffer Details:
   Buffer Type: LINEAR (default)
   Buffer Size (in MB): 1
  File Details:
   File not associated
  Limit Details:
   Number of Packets to capture: 0 (no limit)
   Packet Capture duration: 0 (no limit)
   Packet Size to capture: 0 (no limit)
   Packets per second: 0 (no limit)
   Packet sampling rate: 0 (no sampling)

Copying the buffer content to a pcap file for analysis

SW1#monitor capture trace1 export flash:/trace1.pcap
Exported Successfully


Downloading the file from switch

SW1(config)#
SW1(config)#ip ftp username backup
SW1(config)#ip ftp password backup
SW1(config)#
SW1#copy flash:/trace1.pcap ftp:
Address or name of remote host []? 192.168.40.100
Destination filename [trace1.pcap]?
Writing trace1.pcap !
2511 bytes copied in 2.156 secs (1165 bytes/sec)

To disable the capture rules , follow the standard option to execute the same commands with a 'no' prefix.

Hope its useful to some beginners.

SOLVED - Oracle procedure , trigger , function source code using command line

If you are finding short of a Oracle schema browser such as TOAD , SQL work bench etc , below SQL statements may be handy to get the source code of a object which could be a procedure , trigger , function etc.
 



  • Connect as oracle sysdba or dba user
  • The type of oracle objects which source code may be extracted 

SQL> select distinct(type) from all_source;

PROCEDURE
PACKAGE
PACKAGE BODY
LIBRARY
TYPE BODY
TRIGGER
FUNCTION
JAVA SOURCE
TYPE

  • Sample Query to extract source code of a oracle procedure
SQL> set linesize 120
SQL> set pagesize 0

SQL> select text from all_source where owner='SYSTEM' and type='PROCEDURE' and NAME='ORA$_SYS_REP_AUTH' order by LINE;

procedure        ora$_sys_rep_auth as
begin
  EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.repcat$_repschema TO SYS ' ||
                 'WITH GRANT OPTION';
  EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.repcat$_repprop TO SYS ' ||
                 'WITH GRANT OPTION';
  EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.def$_aqcall TO SYS ' ||
                 'WITH GRANT OPTION';
  EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.def$_calldest TO SYS ' ||
                 'WITH GRANT OPTION';
  EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.def$_error TO SYS ' ||
                 'WITH GRANT OPTION';
  EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.def$_destination TO SYS ' ||
                 'WITH GRANT OPTION';
end;


  • Example to extract a oracle trigger source code

SQL> select text from all_source where owner='SYSTEM' and type='TRIGGER' and NAME='REPCATLOGTRIG' order by LINE;

TRIGGER system.repcatlogtrig
AFTER UPDATE OR DELETE ON system.repcat$_repcatlog
BEGIN
  sys.dbms_alert.signal('repcatlog_alert', '');
END;

Hope this is useful to some SQL beginners

Diameter Credit Control - Session control - Abort Session Answer

A sample Diameter credit control - Session Control - Abort Session Answer (ASA) wireshark capture which may help Diameter base protocol beginners.

Diameter Protocol
    Version: 0x01
    Length: 128
    Flags: 0x40
        0... .... = Request: Not set
        .1.. .... = Proxyable: Set
        ..0. .... = Error: Not set
        ...0 .... = T(Potentially re-transmitted message): Not set
        .... 0... = Reserved: Not set
        .... .0.. = Reserved: Not set
        .... ..0. = Reserved: Not set
        .... ...0 = Reserved: Not set
    Command Code: 274 Abort-Session
    ApplicationId: Diameter Credit Control Application (4)
    Hop-by-Hop Identifier: 0x88f628db
    End-to-End Identifier: 0xc3ef6b84
   
    AVP: Session-Id(263) l=33 f=-M- val=shareo;3640208403;642;9328
        AVP Code: 263 Session-Id
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 33
        Session-Id: shareo;3640208403;642;9328
        Padding: 000000
    AVP: Auth-Application-Id(258) l=12 f=-M- val=Diameter Credit Control (4)
        AVP Code: 258 Auth-Application-Id
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 12
        Auth-Application-Id: Diameter Credit Control (4)
    AVP: Origin-Host(264) l=13 f=-M- val=shareo
        AVP Code: 264 Origin-Host
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 13
        Origin-Host: shareo
        Padding: 000000
    AVP: Origin-Realm(296) l=20 f=-M- val=shareolite
        AVP Code: 296 Origin-Realm
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 20
        Origin-Realm: shareolite
    AVP: Result-Code(268) l=12 f=-M- val=DIAMETER_SUCCESS (2001)
        AVP Code: 268 Result-Code
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 12
        Result-Code: DIAMETER_SUCCESS (2001)
    AVP: Origin-State-Id(278) l=12 f=-M- val=3626120984
        AVP Code: 278 Origin-State-Id
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 12
        Origin-State-Id: 3626120984

Diameter Credit control - Session Control - Abort Session Request

A sample Diameter credit control (DCC) - Session control - Abort session request (ASR) wireshark capture which may help Diameter base protocol beginners.

Diameter Protocol
    Version: 0x01
    Length: 148
    Flags: 0xc0
        1... .... = Request: Set
        .1.. .... = Proxyable: Set
        ..0. .... = Error: Not set
        ...0 .... = T(Potentially re-transmitted message): Not set
        .... 0... = Reserved: Not set
        .... .0.. = Reserved: Not set
        .... ..0. = Reserved: Not set
        .... ...0 = Reserved: Not set
    Command Code: 274 Abort-Session
    ApplicationId: Diameter Credit Control Application (4)
    Hop-by-Hop Identifier: 0x88f628db
    End-to-End Identifier: 0xc3ef6b84
    AVP: Session-Id(263) l=33 f=-M- val=shareo;3640208403;642;9328
        AVP Code: 263 Session-Id
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 33
        Session-Id: shareo;3640208403;642;9328
        Padding: 000000
    AVP: Destination-Realm(283) l=20 f=-M- val=shareolite
        AVP Code: 283 Destination-Realm
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 20
        Destination-Realm: shareolite
    AVP: Destination-Host(293) l=13 f=-M- val=shareo
        AVP Code: 293 Destination-Host
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 13
        Destination-Host: shareo
        Padding: 000000
    AVP: Origin-Host(264) l=23 f=-M- val=shareo1.com
        AVP Code: 264 Origin-Host
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 23
        Origin-Host: shareo1.com
        Padding: 00
    AVP: Origin-Realm(296) l=20 f=-M- val=shareolite
        AVP Code: 296 Origin-Realm
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 20
        Origin-Realm: shareolite
    AVP: Auth-Application-Id(258) l=12 f=-M- val=Diameter Credit Control (4)
        AVP Code: 258 Auth-Application-Id
        AVP Flags: 0x40
            0... .... = Vendor-Specific: Not set
            .1.. .... = Mandatory: Set
            ..0. .... = Protected: Not set
            ...0 .... = Reserved: Not set
            .... 0... = Reserved: Not set
            .... .0.. = Reserved: Not set
            .... ..0. = Reserved: Not set
            .... ...0 = Reserved: Not set
        AVP Length: 12
        Auth-Application-Id: Diameter Credit Control (4)

Enable SNMP traps Cisco Switch SOLVED


In this post , we present the working steps to enable SNMP Traps on a cisco switch.  Hope this is useful to some beginners.

Check the SNMP Trap settings.

SW1#show snmp
Chassis: SRO112WE21
0 SNMP packets input
    0 Bad SNMP version errors
    0 Unknown community name
    0 Illegal operation for community name supplied
    0 Encoding errors
    0 Number of requested variables
    0 Number of altered variables
    0 Get-request PDUs
    0 Get-next PDUs
    0 Set-request PDUs
    0 Input queue packet drops (Maximum queue size 1000)
0 SNMP packets output
    0 Too big errors (Maximum packet size 1500)
    0 No such name errors
    0 Bad values errors
    0 General errors
    0 Response PDUs
    0 Trap PDUs
SNMP global trap: disabled
SNMP agent enabled

SNMP logging: disabled

Enter into configuration mode , to send SNMPV2 traps to manager IP 10.20.30.1 using the interface of VLAN 45 , below commands may be used.

SW1#config t
SW1(config)# snmp-server community public ro
SW1(config)# snmp-server host 10.20.30.1 version 2c public
SW1(config)# snmp-server enable traps snmp
SW1(config)# snmp-server trap-source vlan 45
SW1(config)# end

SW1# show snmp
Chassis: SRO112WE21
0 SNMP packets input
    0 Bad SNMP version errors
    0 Unknown community name
    0 Illegal operation for community name supplied
    0 Encoding errors
    0 Number of requested variables
    0 Number of altered variables
    0 Get-request PDUs
    0 Get-next PDUs
    0 Set-request PDUs
    0 Input queue packet drops (Maximum queue size 1000)
6 SNMP packets output
    0 Too big errors (Maximum packet size 1500)
    0 No such name errors
    0 Bad values errors
    0 General errors
    0 Response PDUs
    6 Trap PDUs
SNMP global trap: enabled
SNMP agent enabled

SNMP logging: enabled
    Logging to 10.20.30.1.162, 0/10, 6 sent, 0 dropped.

Linux iptables sample config file - NAT example

A sample linux iptables configuration file with example of Input , forward and output chain and a forwarding rule using NAT.

# Generated by iptables-save
*nat
:PREROUTING ACCEPT [95879495:41169618280]
:POSTROUTING ACCEPT [108901633:383143482754]
:OUTPUT ACCEPT [108901761:383143490150]

# NAT rule to route traffic from one port to another
-A PREROUTING -i eth0 -p tcp -m tcp --dport 1234 -j DNAT --to-destination 10.20.30.40:1234
COMMIT

# Generated by iptables-save v1.3.5

:INPUT ACCEPT [457337:38416223]
:FORWARD ACCEPT [556:36240]
:OUTPUT ACCEPT [358730:14631762]

-A INPUT -s 10.102.1.1/255.255.255.248 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 14531 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -s 127.0.0.1 -j ACCEPT
-A INPUT -s 69.254.0.0/255.255.0.0 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 0:1023 -j REJECT --reject-with icmp-port-unreachable

# To accept the packets for forwarding
-A FORWARD -i eth0 -j ACCEPT

-A OUTPUT -s 127.0.0.1 -j ACCEPT
-A OUTPUT -d 10.30.40.50 -j ACCEPT
-A OUTPUT -d 20.45.55.65 -p tcp -m tcp --dport 22 -j ACCEPT
-A OUTPUT -d 34.35.36.34 -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -s 69.254.0.0/255.255.0.0 -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -d 127.0.0.1 -j ACCEPT
-A OUTPUT -j LOG --log-prefix "IPTABLES-OUT Default Drop: " --log-level 7
-A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 21 -j ACCEPT
COMMIT

Expect sample script SSH command execution

A sample expect interactive script to SSH to a server , feed in a pre-configured username and password and execute a remote script. 

#!/usr/bin/expect
log_user 0
set timeout -1
spawn ssh root@localhost /home/shareo/test.sh
expect "root@localhost's password:"
send "share1234\r"
log_user 1
expect "##END##"

Hope this is useful to some beginners.

–>