Error With Unix Script

Hi,

I have a written a script:
Code:
#!/usr/bin/ksh
#--------------------------------------------------------------------------------------------------------------#
#qz='sqlplus barcqz/xdr56yhn@BARP2'
#wdc='sqlplus barcwdc/xdr56yhn@BARP2'
#--------------------------------------------------------------------------------------------------------------#
sqlplus barcqz/xdr56yhn@BARP2 <<EOF
update qz_dates set QZ_DT = sysdate;
update qz_dates_back set QZ_DT = sysdate;
update wdc_dates set WDCDATE = sysdate;
update WDC_PAY_EXRATE set WPESENTDATE = to_char(sysdate,'DD-MON-YY:HH:MI:SS') ;
update WDC_OU_STARTTIME set WOSBUSINESSDATE =sysdate;
commit;
exit
EOF

sqlplus barcwdc/xdr56yhn@BARP2 <<EOF
update WDC_PAY_EXRATE set WPESENTDATE=(substr(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),1,10)||'T'||substr(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),12,19));
commit;
exit
EOF

when i run this script on command prompt, it runs well, but when i schedule it in crontab, it gives an error as:

Code:
/devapp1_01/quartz/qzprod1/santosh/scripts/update_date.sh[6]: sqlplus:  not found.
/devapp1_01/quartz/qzprod1/santosh/scripts/update_date.sh[16]: sqlplus:  not found.
/devapp1_01/quartz/qzprod1/santosh/scripts/update_date.sh[6]: sqlplus:  not found.
/devapp1_01/quartz/qzprod1/santosh/scripts/update_date.sh[16]: sqlplus:  not found.

could someone please help on this?


Similar Content



Problem In Executing Script Through Crontab

Hi,
I have written one script which is connecting to the the daabase and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is genearting and working fine but same script when i have configured in crontab not working and giving error, kindly help.

script contents:

#!/bin/bash
sqlplus -s /nolog << EOF
CONNECT plmc/plmb@whb
@csvgenerator.sql
end;
/
EOF
-----------------------------------
Script running successfully as below, though it is giving below message but running fine

$ sh test.sh
SP2-0734: unknown command beginning "sqlplus ct..." - rest of line ignored.

Session altered.
CSV geneartaed

Same Script giving error while triggering by crontab as below

$ sqlplus: not found

Problem W/.bash Script... Need Help

I'm trying to loop through a query in SQLDeveloper by passing the query a different Period and I'm having a problem getting the syntax correct.

Individually the following works correctly on its own:

Code:
#!/bin/bash
 for i in `seq -f "%02g" 1 5`;
    do
    echo $i
 done

$ ./test.sh
1
2
3
4
5

the following also executes correctly:

Quote:
sqlplus table1/$userpass@Mytable <<EOF
@./sqlcode.sql $i
EOF
but when I try to wrap the loop around my sqlplus command

Code:
#! /bin/sh
userpass=read
for i in `seq -f "%01g" 1 3`;
  do
        sqlplus -S  table1/$userpass@Mytable <<EOF
        @./sqlcode.sql $i
        EOF
done

I get the following error:

./test.sh: line 13: syntax error: unexpected end of file

Does anyone have any ideas on what's going on?

Best Way To Run Two Interdependent Scripts

Hi All,

I have two scripts, the aim of these two scripts is, to check whether a particular script is running or not, if it wont runs, then throw a mail.

How i Achieved this output is, I wrote first script.

I created an infinite while loop which performs below steps

1. It creates a touch file
2. Triggers the script which needs to be monitored if its working or not.
3. Removes the touch file.

If the second step fails, then the remove file command will not happen and the script will stuck there itself.

I created an another script which checks the creation time of the touch file and if it is more than ten minutes, it means the second step in the first script is hanged, which also means that particular script is not working.

So if the creation time is more than 2 minutes the second script will throw a mail.

Below are the two scripts.

Code:
#!/bin/ksh



userid="chansd"

filename="/apps/log/check.txt"

while true ;do
touch $filename
pass=`/apps/eDMZ/call_st.ksh $userid`
sleep 20
rm $filename
done

Below script checks the file creation time and throws email if it is older than 2 minutes
Code:
#!/bin/ksh


filename="/apps/log/check.txt"

if [ -f "${filename}" ]
then
if test "`find $filename -mmin +2`"
then
echo "script is not working ! Please act on it" | mail -s "Script  is not working" Example@mail.com
fi


else

        exit 1

fi


What im going to do is

1. I am going to run the first script in background so it runs forever.
2. I am going to run the second script in cron forevry 5 mins to check the file creation time.

3. So if the first script hangs . I will kill the process using process id and after the issue resolves with the inner script, I will run the main script again.

I am new to Linux, Please let me know if this approach will work as expected.

Debian 7 Ssh Error: -bash: Apy-get: Command Not Found

Hi

I just got a vps server and i try to run apt-get update and i got this:

Code:
-bash: apt-get: command not found

Any ideas how to fix it?

Even if i try manual to install it i am getting:

Code:
configu  error: cannot run /bin/sh buildlib/config.sub

dpkg also missing and gcc compiler ....

Thanks

Update Grub Command Not Working

I have made a change to GRUB2 bootloader in etc/default/grub.
Now I need to run 'update grub' for the change to take effect.
However, the 'update grub' command on the terminal is giving this error message:
Code:
root@debian:/# update grub
bash: update: command not found

Can someone please explain why this command is no longer working?

I've had to make a change to grub because I tried to install a new distro which meant I had to alter grub.
The install wasn't successful so I deleted the grub file and then re-installed it.
The re-installed grub needs a change so I can get sound on my pc.
However, I can't add these changes because the 'update grub' command doesn't work.

I've checked the grub file with another debian distro and they are both the same.
So now I don't know if I need to check if a different grub file is the problem or anything else.
Can someone help?

Scripts To Respond To Prompts

I have searched and was unsuccessful in finding a quick command or example to use.

I'm looking to automate an update process using command line in Debian.
Normally I'd use apt-get update|upgrade|dist-upgrade .

If apt-get finds a package to update it queries a Y/n response.
My objective is to have a script determine if this prompt is there, and if so to respond with 'Y'.
If not then it should not enter a response.

I know I'll need to use an IF/ELSE function, but what I'm having difficulties locating is to read the output of apt-get .

I know there's books and sites available, but they are all long and sometimes difficult to read or understand. And maybe my keywords are the right ones to use, as I'm not able to pinpoint a solution.

Thanks for your assistance.

Is LFS The Right Way To Build A Software Update Disk?

I'm very used to working on a linux machine, programing in Unix terminals all through college. That said, I have never needed to work with linux distributions or doing more than some apt-get software installation.

I need to make a CD. I need a machine to be able to boot from this CD. I would like there to be a unix terminal that runs a script automatically. This script must be able to mount an NFS drive, do simple networking (TCP/IP), and update the software on the machine running it through deleting/adding files.

I guess I need an .iso for a linux distro that has files and a script already on it that can be used to update a bunch of these specific machines?

Should I go through the LFS project in order to learn how to do this?

I'm pretty lost and need some help. Thanks!

Sending SMB Client Commands Through Shell Script

Hello.

I have a shell script, which I am using to access the SMB Client:

Code:
#!/bin/bash
cd /home/username
smbclient //link/to/server$ password -W domain -U username
recurse
prompt
mput baclupfiles
exit

Right now, the script runs, accesses the server, and then asks for a manual input of the commands.

Can someone show me how to get the commands:
Code:
recurse, prompt, mput baclupfiles and exit

to be run by the shell script please?

Cron.daily Symlink (double) Does Not Seem To Be Executing?

Hello,

I cannot understand why the symlink I have put in /etc/cront.daily won't work. It is very possible I am wrong, but my understanding is that cront.{daily,weekly,monthly} works fine with symlinks.

Basically it is double symlink-ed. ls -la on /etc/cron.daily looks like this:

Code:
... 
lrwxrwxrwx  1 root root    49 Nov 27 18:26 rsync_mysql_backups.sh -> /home/myuser/scripts/bash/rsync_mysql_backups.sh
...

Now, ls -la on /home/myuser/scripts looks like this:

Code:
...
lrwxrwxrwx 1 myuser myuser    26 Sep 20  2013 scripts -> /media/md1_storage/scripts
...

I couldn't see anything suspicious in syslog, so I installed postfix in the hope that I will get some sort of information there. Nothing... I also redirected the output of the script to a file in /home/myuser/log.txt but nothing there. The file was not even created.

I am not doing anything mad in the script, I am just synchronising a local directory with a remote one like this:

Code:
/usr/bin/rsync -avzx -e 'ssh -i "/home/myuser/.ssh/myremotehost/id_rsa"' /media/md1_storage/backups/stuff/ myuser@myremotehost:/srv/backups/stuff/ >> /home/myuser/log.txt 2>&1;

As other people suggested in similar threads, I have verified that
Code:
test -x /usr/sbin/anacron

is false, which will result in the execution of the second part of the entry in /etc/crontab:

Code:
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

Any input will be much appreciated. I know I am doing something wrong, but I just cannot see it right now... How can I gather more debugging which will help me understand what's going wrong?

Thanks!

Duplicate Folder Creation While Using Mkdir In A Script

Hello,

I am setting up a linux server for gaming and I am using a script to update the files automatically and create a folder with a certain name.

Code:
# !/bin/bash

# A convenience function, to save us some work
update_server() {
	# Read the app id and the directory into a variable

	APP_ID=$1
	DIR=$2

	# Create the directory ( if it does not exist already )
	if [ ! -d "$HOME/$DIR" ]; then
		mkdir -p "$HOME/$DIR"
	fi

	# Uh-oh, it looks like we still have no directory. Report an error.
	if [ ! -d "$HOME/$DIR" ]; then
		# Describe what went wrong
		echo "ERROR! Cannot create directory $HOME/$DIR!"

		# Exit with status code 1 ( which indicates an error )
		exit 1
	fi

	# Call SteamCMD with the app ID we provided and tell it to install
	./bin/steamcmd.sh +login anonymous +force_install_dir "$HOME/$DIR" +app_update $APP_ID validate +quit
}

# Now the script actually runs update_server ( which we just declared above ) with the id of the application ( 4020 is Garry's Mod ) and the name of the directory we want the server to be hosted from:

update_server 4020 "gmodserver"

exit 0

When I run this script, it creates 2 folders on my server : gmodserver and gmodserver? There is no files downloaded in gmodserver. All the files are downloaded in gmodserver?

I looked for a few hours on how to solve this problem but I have no idea what the added ? might be so I am lost as to what to look for. Could you help me on figuring this out?

Thank you.

edit : I am using ubuntu 15.04 x64 if it makes a difference.