Call a script from an other script

Fermé
manshoto Messages postés 1 Date d'inscription jeudi 18 avril 2013 Statut Membre Dernière intervention 18 avril 2013 - 18 avril 2013 à 20:00
mamiemando Messages postés 33606 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 26 mars 2025 - 19 avril 2013 à 00:21
Hi all,

I have 2 different script (SCRIPT A and SCRIPT B)

SCRIPT A is on SERVER 1 and SCRIPT B is on SERVER 2

SCRIPT A do data processing and SCRIPT B loads these data.

I need only one script instead of 2 which will process data on SERVER 1 and load them on SERVER 2 by using my 2 scripts

********************************************************
SCRIPT A on SERVER 1:

#!/bin/sh

#TIME="'date '+%Y%m%d''"
HOST='10.171.16.30'
USER='qosuser'
PASSWD='qos1user'

./npa_ParseAndLoadObject_CELLCCHDR.sh
./npa_ParseAndLoadObject_CELTCHF.sh
./npa_ParseAndLoadObject_CELTCHH.sh
./npa_ParseAndLoadObject_CLSDCCH.sh
./npa_ParseAndLoadObject_CLTCH.sh

cd /export/home/qosuser/MISC/results/

#cd pmexport_$TIME

ftp -n ${HOST} << EOF
user ${USER} ${PASSWD}
cd /export/home/qosuser/MISC/results
prompt n
mput CELLCCHDR.sgw
mput CELTCHH.sgw
mput CELTCHF.sgw
mput CLTCH.sgw
mput CLSDCCH.sgw
bye
EO

**********************************************

SCRIPT B on SERVER 2:

! /bin/ksh
#########################################################################
# $ID : npa_RadioKPI_LoadObject.sh
# Author: Karamoko MAMADOU, QoS Engineer for Moov CI
# Date : 2013/03/08
#
#
# Change history
#========================================================================
# Load only Object parsed fron oldossserver and transfered by ftp
#########################################################################

INPUTDIR="$HOME/MISC/results"
DBDIR="/opt/mysql/mysql/data/radio_kpis"
SGWDIR="$HOME/MISC/resultsSGW"
TIME="'date '+%Y%m%d%H%M%S''"

# Backup File to a folder

cp "${INPUTDIR}/CELLCCHDR.sgw" ${SGWDIR}/CELLCCHDR_$TIME.sgw


# Copy File to be loaded into mysql import folder prior for loading into database

cp "${INPUTDIR}/CELLCCHDR.sgw" ${DBDIR}/cellcchdr.csv

# Import data into database in specified table

cd $DBDIR

mysqlimport --user=pmdbuser --password=pmdbuser1 -r -s --fields-terminated-by=";" --lines-terminated-by="\n" radio_kpis cellcchdr.cs

*********************************************************************

Need help

Thx
A voir également:

1 réponse

mamiemando Messages postés 33606 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 26 mars 2025 7 836
19 avril 2013 à 00:21
In script1, you can run scrip2 by using the following command (assuming that (1) user can run script2 on server2 (2) you have enabled a ssh key on server1 for user@server2 (3) sshd is running on server2):

ssh user@server2 /path/to/script2


NB: you're supposed to speak french in this forum :-)

Cheers
0