Tag Archives: USER

How to display files of server2 in server1?

By Little

hi,

i have two servers in unix. say server1 and server2. my shell script is running on server1.

In server2, there is a directory (/etc/data/) which contains some text files.

I want to write the list of filenames in server2 in a file and display the file in server1.

In short, i want to display the filenames present in server2 in server1.

i thought i can use FTP like..

Code:

ftp server2 <<FTP1
quote USER aaaa
quote PASS bbbb
cd /etc/data
Files=`ls -l | cut -c45-`
FTP1


In the aboce code i tried to populate a variable with the file names which are present in server2, but it doesnt work.

can any1 help doing this? or suggest some other method..

Thanks

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Shell : sftp autologin not working …

By scriptscript

Hi folks,

for sftp autologin, while browing in unix.com forums.. I got the below code. I tried to execute that code but no luck.

Code:

#!/bin/sh
HOST=yourservername
USER=yourusername
PASS=yourpassword
echo "sftping file ..."
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
cd /tmp
get tmpfile
bye
EOF
echo "done"


the error message is as follows

Code:

ubuntu1[johng]/mypath>sh sftp_new.sh
sftping file ...
sftp_new.sh: line 8: lftp: command not found


Could anyone please help me what went wrong….

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Need to split a string

By adshocker

Hi,

We have a SunOS 5.10 Generic_142900-13 sun4v sparc SUNW,T5240.

I’m trying to find a way to split a string into 2 variables.

Ex:
parm1=”192.168.1.101/parent/child”

What I need to do is split the string above into:

host=”192.168.1.101″
location=”parent/child”

I saw the solution provided here http://www.unix.com/shell-programmin…tion-file.html but somehow we don’t have the -o option for grep as I keep getting illegal option –o.

The purpose of this is for a shell script already created to do an FTP function. Originally it was intended for accepting HOST, USER, PASS and FILE parameters only. Basically file goes to whatever the main directory on FTP connect. Now users are passing HOST/folder as value for HOST parameter which gives out an error now since 192.168.1.101/parent/child is not a valid HOST. And it would be a lot of work to add another parameter for LOCATION because a lot of other programs are already using this script so I’m trying to avoid this solution for now.

I’d appreciate any suggestions.

Thanks.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How to produce a executable Oracle script from bash script?

By jediwannabe

Hi here’s my code

Code:


${ORACLE_HOME}/bin/sqlplus /nolog <<!EOF
--step 5 create db script start
set feedback off
set heading off
set echo off
conn / as sysdba
spool ${ORACLE_SID}_db_link.sql

SELECT 'CREATE '||DECODE(U.NAME,'PUBLIC','public ')||'DATABASE LINK '||CHR(10)
||DECODE(U.NAME,'PUBLIC',Null, 'SYS','',U.NAME||'.')|| L.NAME||chr(10)
||'CONNECT TO ' || L.USERID || ' IDENTIFIED BY "'||L.PASSWORD||'" USING
'''||L.HOST||''''
||chr(10)||';' TEXT
FROM SYS.LINK$ L, SYS.USER$ U
WHERE L.OWNER# = U.USER#;

spool off

set feedback on
set heading on
set echo on

!EOF


here’s the output where i run the script

Code:

[oracle@TU-RH5 manual_upgrade]$ export ORACLE_SID=SUPERB
[oracle@TU-RH5 manual_upgrade]$ /home/oracle/chunhung/NI/manual_upgrade/create_db_link.sh

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Feb 5 17:59:16 2013

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

SQL> SQL> SQL> SQL> SQL> Connected.
SQL> SQL> SQL> 2 3 4 5 6 7
CREATE DATABASE LINK
SUPERB_ADMIN.UEM_CBS_DBLINK
CONNECT TO ABC_ADMIN IDENTIFIED BY "" USING
'/s01/oracle/product/10.2.0/db_1'
;

SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


my output file SUPERB_db_link.sql

looks like the following

Code:

SQL>
SQL> SELECT 'CREATE '||DECODE(U.NAME,'PUBLIC','public ')||'DATABASE LINK '||CHR(10)
2 ||DECODE(U.NAME,'PUBLIC',Null, 'SYS','',U.NAME||'.')|| L.NAME||chr(10)
3 ||'CONNECT TO ' || L.USERID || ' IDENTIFIED BY "'||L.PASSWORD||'" USING
4 '''||L.HOST||''''
5 ||chr(10)||';' TEXT
6 FROM SYS.LINK$ L, SYS.USER$ U
7 WHERE L.OWNER# = U.USER#;

CREATE DATABASE LINK
SUPERB_ADMIN.UEM_CBS_DBLINK
CONNECT TO ABC_ADMIN IDENTIFIED BY "" USING
'/s01/oracle/product/10.2.0/db_1'
;

SQL>
SQL> spool off


unfortunately this is not what I want.

what I want is

Code:

CREATE DATABASE LINK
SUPERB_ADMIN.UEM_CBS_DBLINK
CONNECT TO ABC_ADMIN IDENTIFIED BY "" USING
'/s01/oracle/product/10.2.0/db_1'
;


would really appreciate if someone could help me on this!

thanks a lot!

Source: FULL ARTICLE at The UNIX and Linux Forums

Need help to kill pids

By prany_cool

Hi there !!!
I am writing a script to kill the pids on different linux boxes 😎

the output of my command gives the pids running on that box, but how can I kill all the pids without looping? :confused:

Code:
ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk ‘{print $2}’ | kill

error: 😮
Usage: kill [-l] [-n signum] [-s signame] job …
Or: kill [ options ] -l [arg …]

I tried to dump the output to a file and able to kill the pids using for loop, but looking for one-line code :b:

ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk ‘{print $2}’ | (how_can_i_kill_here) :wall:

Thanks for the help 🙂

have a good day

Source: FULL ARTICLE at The UNIX and Linux Forums

Ftp gettting disconnected

By Tommyk

All,

Trying to ftp to a remote ftp server.

See following output:


ftp -dv xx.xx.xx.xx
Connected to xx.xx.xx.xx (xx.xx.xx.xx).
220 Microsoft FTP Service
Name (xx.xx.xx.xx:username): ftpuser
---> USER ftpuser
331 Password required for ftpuser.
Password:
---> PASS XXXX
230 User logged in.
---> SYST
215 Windows_NT
Remote system type is Windows_NT.
ftp> passive
Passive mode off.
ftp> ls
---> PORT xx,xx,xx,xx,xx,xx
200 PORT command successful.
---> LIST
125 Data connection already open; Transfer starting.
02-20-12 09:55AM 113129
08-28-12 10:03AM 115058
09-10-12 12:53PM 115143
09-13-12 02:43PM 115265
09-24-12 06:51PM 115334

226 Transfer complete.
ftp> ls
---> PORT xx,xx,xx,xx,xx,xx
421 Service not available, remote server has closed connection


This is from RHEL5.8 using ftp 0.17-37.el5

Every connection is successful, there is a timeout set but does not seem to be affecting this. As soon as we connect we run an ls command which is successful and less than a second later you run the ls command again and getting the message that you have been disconnected from the server.

This happens after any/every data transfer whether it is ls/dir/put/get, you only get a single data transfer and then you are disconnected.

Using HP-UX previously there was no issue, there has been no change to the ftp server, windows desktops can connect and do not get disconnected, i am also getting the same issue with OEL5.5 servers.

This is not a network/firewall issue as all the network settings are the same for every client we use. It is not an issue with active or passive mode as both modes show the exact same symptoms. However testing ftp from the linux client we can connect to every other ftp site without issue both within and external to the firewall and do not get the same error.

Can anyone suggest why this may be happening? Could it be due to the version of ftp we are using?

Source: FULL ARTICLE at The UNIX and Linux Forums

Help/Advise on parsing these line of text

By newbie_01

Hi,

Can anyone please advise how do I parse the following line of strings?


14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1552)) * establish * test * 0
14-OCT-2012 06:39:15 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINRWRBE60.exe)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1574)) * establish * test * 0
14-OCT-2012 06:40:48 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8200XXX138060Z)(USER=mouse))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.217.35.94)(PORT=2525)) * establish * test * 0
14-OCT-2012 07:01:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=server911)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=test)(VERSION=135296000)) *
status * 0


– I am wanting parse or de-construct it so that I can get the HOST, PROGRAM and USER

– awk’s -F and cut only accept single delimiter so am lost on how to parse these strings.

– Feedback/advise much appreciated. Thanks in advance.

Source: FULL ARTICLE at The UNIX and Linux Forums

Help with awk using * (asterisk) as the delimiter

By newbie_01

Hi

I am trying to parse the following lines and has to use * (asterisk) as the delimiter.

These lines are in a file, for example tmp.txt and I am using a while loop


tmp.txt:

14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey
))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1552)) * establish * test * 0
14-OCT-2012 06:39:15 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINRWRBE60.exe)(HOST=8000XXX05004RV)(USER=mickey
))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1574)) * establish * test * 0
14-OCT-2012 06:40:48 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8200XXX138060Z)(USER=mouse))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.217.35.94)(PORT=2525)) * establish * test * 0
14-OCT-2012 07:01:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=server911)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=test)(VERSION=135296000)) *
status * 0

- while loop code block

while read line
do
echo " ---> Parsing ---> "
echo " - $line"
echo ""
timestamp=`echo $line | awk -F* '{ print $1 }'`
echo " - timestamp = ${timestamp}"
echo ""
echo ""
done < ${pid}.tmp.01


Instead of just getting the timestamp, I am getting the timestamp plus what looks like a directory listing of all files, i.e. like a timestamp and echo * of the directory that I am in.

Can anyone please advise how to get around this?

Feeback/advise much appreciated. Thanks in advance.

Source: FULL ARTICLE at The UNIX and Linux Forums

Merge different versions of file in UNIX

By AjMyTechGroup

Hello Experts,
I want to merge my local file (File1) with the changes in remote server (File1). For Example:

File1 contents are… (file @ remote server)
ABC

GHI

I, as USER#1, have updated the contents of File1 in my local as…
ABC
DEFGhi

JKL

meanwhile, some USER#2, have already commited the new changes in remote server repository…now the File1 contents, @ remote server, are…
ABC
123DEF
GHI

Now, I don’t want to simply replace remote File1 with my local File1 coz by doing so, I might overwrite on USER#2 changes. So now I need to merge the latest file in remote server repository with my local file changes (without changing the sequence). Can anyone please help?

Source: FULL ARTICLE at The UNIX and Linux Forums

Bash – OR within an IF statement

By jimbob01

Hey guys,

Currently trying to write a wee script that runs only when logged in as one of two users. The rest of the script is working fine, but no matter what user I try to run it as, it always fails! This is the puzzling part:

Code:

if [[ $USER != "admin1" || $USER != "admin2" ]]; then
echo "Run script as admin "
exit 1
else
... runs some script . . .
fi


Does anyone have any ideas !? It’s probably staring me straight in the face but as I’m still learning bash/scripting then it’s going right past me!

Thanks guys for any help

Jim

Source: FULL ARTICLE at The UNIX and Linux Forums