Operating System - HP-UX
1834497 Members
2692 Online
110067 Solutions
New Discussion

Re: script to submit files in a directory

 
steven Burgess_2
Honored Contributor

script to submit files in a directory

Hi all

I have a whole bunch of files in a directory that require a command to resend them to various servers, the command is

#su - dssadmin
#connect
#submit file=/tmp/xeSndCube_CC_C_.

I want to use a simple script to send them

while [ -f /tmp/xeSnd* ]
do
su - dssadmin
connect
submit file==/tmp/xeSnd*
done

Will the above attempt to submit each of the files individualy ?

I can't test the above as it's a production server

Thanks in advance

Steve
take your time and think things through
6 REPLIES 6
steven Burgess_2
Honored Contributor

Re: script to submit files in a directory

Hi

It works

I tested it with a bunch of files and just moved them to another directory

Any further ideas will be great

Steve
take your time and think things through
someone_4
Honored Contributor

Re: script to submit files in a directory

Hi steven
I am wondering is there a reason why you choose su though a script? When I have to transfer files I usualy use rcp. Do you have remsh shell set up? Yuo can test it by doing something like

remsh servera hostname

If that works you can do your rcps like this hostnames.all would be a file with all the hostnames you want to put the file into in one colum.

#! /bin/sh
REMOTES=hostnames.all
for REMOTE in $(cat $REMOTES)
do
echo '#####################'
echo ""
# here you check the hostname of the server this
# is optional
remsh ${REMOTE} -l root "hostname"
#here you copy from your directory to the remote
#server from teh hostnames.all file
rcp -p /home/whatever/file ${REMOTE}:/home/otheruser/
# here we check in the /home/otheruser for the file
remsh ${REMOTE} -l root "ll /home/otheruser/file"
done

Richard
steven Burgess_2
Honored Contributor

Re: script to submit files in a directory

Hi Richard

I suppose the submit for file in is quite simple. I've been looking into this further

The user dssadmin is a connect direct user

so typing connect from the prompt as the user opens a connect direct session.

Here's the correct scenario

I get an alert saying 'one or more files have not been sent'

I check for file in a directory

/var/local/xe/dss/PROD/logs/connectd

The files that require re submitting are of the same name in /tmp

I then create connect direct session

#direct

submit file=/tmp/xeSnd*

so what would be the correct syntax :-

for file in /var/local/xe/dss/PROD/logs/connectd/xeSend*
do
su - dssadmin
direct
submit file=/tmp/xeSend*

and send the output of each submit to a file

Regards

Steve



for file in /var/local/xe/dss/PROD/logs/connectd
do
su -





take your time and think things through
steven Burgess_2
Honored Contributor

Re: script to submit files in a directory

Hi Rich

I'm just going on my break to watch the football

Cheers

Steve
take your time and think things through
steven Burgess_2
Honored Contributor

Re: script to submit files in a directory

Hi

Just in case anyone is interested

#!/usr/bin/sh
su - dssadmin
cd $XELOGD/connectd
ls xeSnd* > $XELOGD/connectd/cube
CUBES=cube
for file in $(cat $CUBES)
do
direct
sleep 5
submit file=/tmp/$file >> /tmp/ps.out 2> /tmp/errors
done

Regards

Steve
take your time and think things through
steven Burgess_2
Honored Contributor

Re: script to submit files in a directory

Hi

Hmmm it doesn't work , i tested it using a file in my ~ and ~/sendit

cd /home/H092AHE
ls xeSnd* > /home/H092AHE/cube
CUBES=cube
for file in $(cat $CUBES)
do
export $file
direct
sleep 5
submit file=/home/H092AHE/sendit/$file > /tmp/cube.out 2> /tmp/cube.err
done

When It attempts to export $file I get the message

./sendit[6]: xeSndCube_CC_C_.21890: is not an identifier

I am going to stop replying to myself now

anyone?

Regards

Steve


take your time and think things through