Shell Script behaves different and wrong on OEL5 then SUSE 11
Hi all ,
I execute following script on SUSE11 and receive the following output as expected and as it should be.
$ echo "\nxxxx\tyyyy\ndddd"
<newline>
xxxx<tab>yyyy
dddd
$
But when I execute same command on OEL 5.2 , following output is coming which shows that "newline" and "tab" are not recognized and behaved as text.
$echo "\nxxxx\tyyyy\ndddd"
\nxxxx\tyyyy\ndddd
Please can some one explain to me why .
I have many shell script and they are not working properly now on OEL.
Hi ,
I had a look to man page of echo and seen that -E option of echo command is enabled by default.
I craeted an alias echo="echo -e" in user profile and scripts are running now properly.
Thank you .
Leo.
Similar Messages
-
Execute process (shell script) under different user
Hi,
is it possible to use the ProcessBuilder oder .exec()-method to execute a shell script under a JVM-different user? I need to start shell scripts for different system users and I don't want to use SUDO or a wrapper script to switch to the required user. I would like to define the user at java level. Is this possible?
Best regards,
Thomaslooking for something like this too.
currently i am relying on a script in which i have to set the user as:
"su username -c java_program"
the problem with this approach is that if youre not running as root, then su asks for a password, thereby halting execution. (tried input redirects and here-docs, (some popular linux tricks), they did not work)
so you have to be root for the script option to work.
if anyone can suggest a more "java based" way of executing a process as a different user , thatll be awesome. -
Shell Script for Startup and Shutdown the database
Hi,
i want Shell Script for Startup and Shutdown the database in Solaries.
could any one can hep me where i can get this script. or send to me to [email protected]
Thanks & Regards,
Gangi reddySHUTDOWN
SHUTDOWN ABORT]
Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
Terms
Refer to the following list for a description of each term or clause:
ABORT
Proceeds with the fastest possible shutdown of the database without waiting for calls to complete or users to disconnect.
Uncommitted transactions are not rolled back. Client SQL statements currently being processed are terminated. All users currently connected to the database are implicitly disconnected and the next database startup will require instance recovery.
You must use this option if a background process terminates abnormally.
IMMEDIATE
Does not wait for current calls to complete or users to disconnect from the database.
Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
NORMAL
NORMAL is the default option which waits for users to disconnect from the database.
Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
TRANSACTIONAL [LOCAL]
Performs a planned shutdown of an instance while allowing active transactions to complete first. It prevents clients from losing work without requiring all users to log off.
No client can start a new transaction on this instance. Attempting to start a new transaction results in disconnection. After completion of all transactions, any client still connected to the instance is disconnected. Now the instance shuts down just as it would if a SHUTDOWN IMMEDIATE statement was submitted. The next startup of the database will not require any instance recovery procedures.
The LOCAL mode specifies a transactional shutdown on the local instance only, so that it only waits on local transactions to complete, not all transactions. This is useful, for example, for scheduled outage maintenance.
Usage
SHUTDOWN with no arguments is equivalent to SHUTDOWN NORMAL.
You must be connected to a database as SYSOPER, or SYSDBA. You cannot connect via a multi-threaded server. For more information about connecting to a database, see the CONNECT command earlier in this chapter.
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013607
Joel Pérez -
[SOLVED] advanced shell script for mount and unmount samba share
Good morning guys,
Today I've a very long question....
Hope in your help....:
I usually move from different network.
For one of those I need to mount some share that are under an ActiveDirectory server.
To do that I use samba.
Especially I've made and use the below shell script.
I know that it's so stupid but I'm a very newbie:
#!/bin/sh
echo "This is a custom script for mount my citrix share"
echo "Please insert user password (must a sudoer user)"
echo " "
sudo mount -t cifs -o username='myusername',password='mypassword' //host_ip/TsHome$/myusername /home/myuser/samba_share/TsHOME
sudo mount -t cifs -o username='myusername',password='mypassword' "//host_ip/direction" /home/myuser/samba_share/direction
echo " "
read -p "Press ENTER key to close this terminal"
exit
As I say the script work but it's so crude...!
I want/need to implement it whit the follow addictions:
1. print a feedback on mount: somenthing like "TsHOME is now mounted" or "unable to mount TsHOME"
2. check if the share are already mounted: to prevent accidentally multiple mount. If a share is already mounted I want to print something like "TsHOME is already mounted on /home/myuser/samba_share/TsHOME"
3. ask for share password (now it's in clear on script) - This is optinal
4. un-mount the share before reboot or shutdown command. That because I've notice that If i reboot or shutdown without manually un-mount the share the step of unmounting network file system became very slow
If it's no extremely difficult, can someone help me to write this script?
I know that man exist but I'm not a programmer and it's so difficult for me approch it.
Thank you in advance.
Ale
Last edited by Alexbit (2010-09-23 21:29:13)Thank you very (VERY) much!
I've follow your information and.. it work!
If can be usefull to other this is the complete script:
#!/bin/sh
echo "This is a custom script for mount citrix share"
echo "****************************************"
echo " "
echo "Please insert domain password:"
read -s mypassword
echo " "
echo "|checking mount state...in share are not mounted mount it!|"
echo "+-------------------------------------------------------------------------+"
if grep "TsHome" /etc/mtab &>/dev/null; then
grep "TsHome" /etc/mtab | awk '{print "TsHome is already mounted on " $2}'
else
sudo mount -t cifs -o username='yourusername',password="$mypassword" //ipaddress/TsHome$ /home/Samba_share/TsHOME && echo "TsHOME is now mounted" || echo "unable to mount TsHOME"
fi
echo " "
if grep "direction" /etc/mtab &>/dev/null; then
grep "direction" /etc/mtab | awk '{print "direction is already mounted on " $2}'
else
sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/direction' /home/Samba_share/direction' && echo "direction pat is now mounted" || echo "unable to mount direction"
fi
echo " "
if grep "Area" /etc/mtab &>/dev/null; then
grep "Area" /etc/mtab | awk '{print "Area is already mounted on " $2}'
else
sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/Area' /home/Samba_share/Area && echo "Area is now mounted" || echo "unable to mount Area"
fi
echo " "
echo "All DONE!"
echo " "
read -p "Press ENTER key to close this terminal"
exit
I don't really well understand what I've to put in rc.local.shutdown....
I think somethings like:
#!/bin/bash
# /etc/rc.local.shutdown: Local shutdown script.
echo "This is a custom script for UN-mount citrix share"
echo "********************************************"
echo " "
echo "|check mount state: if mount then un-mount!|"
echo "+-------------------------------------------------------+"
echo " "
if grep "TsHome" /etc/mtab &>/dev/null; then
grep "TsHome" /etc/mtab | awk '{print "TsHome is NOT mounted -> going on..." $2}'
else
sudo umount /home/Samba_share/TsHOME && echo "TsHOME is now UN mounted" || echo "unable to UN-mount TsHOME"
fi
echo " "
if grep "direction" /etc/mtab &>/dev/null; then
grep "direction" /etc/mtab | awk '{print "direction is NOT mounted -> going on.." $2}'
else
sudo umount /home/Samba_share/direction && echo "direction is now UN mounted" || echo "unable to UN-mount direction pat"
fi
echo " "
if grep "Area" /etc/mtab &>/dev/null; then
grep "Area" /etc/mtab | awk '{print "Area is NOT mounted - Finished" $2}'
else
sudo umount /home/Samba_share/Area && echo "Area is now UN mounted" || echo "unable to UN-mount Area"
fi
echo " "
echo "going shutdown"
echo " "
sleep 5
I've try but it seems to ignore the IF statement... this is the output when ALL share are UNmounted:
$ sh /etc/rc.local.shutdown
This is a custom script for UN-mount citrix share
|check mount state: if mount then un-mount!|
+-------------------------------------------------------+
umount: /home/Samba_share/TsHOME: not mounted
unable to UN-mount TsHOME
umount: /home/Samba_share/direction: not mounted
unable to UN-mount direction
umount: /home/Samba_share/Area: not mounted
unable to UN-mount Area
going shutdown
Tomorrow I will test again when I'm at office.
Meanwhile can you check if I made a macroscopic mistakes?
Thank you again!
Last edited by Alexbit (2010-09-23 17:34:49) -
Shell script for moving and renaming files
I'm not so familiar with shell scripts. I have created some simple scripts for various tasks but now I hit something I can't handle myself.
My server receives every night a logfile from another server. This file I need to rename and move to another location. Problem is that a simple mv with new filename isn't enough, I need to insert date in filename. Format for date should be ddmmyy. Also the name of incoming file changes every night. The output always starts with same letters, let's say "log", and the date is used to identify files.
For example I receive a file /Input/filename.log and I need to move the file to the folder /Output with name log130308.txt.
Any tips how to insert the date as part of of filename while renaming or moving the file? I prefer shell script as I'll use launchd for scheduling the script.Hi again,
so far I've constructed this:
cd /input
for file in `ls *log`
do
echo "Copying " $file
cp $file /output/log.$file.`date +%d%m%y`
done
Quite there. I'm cding to directory, i'll focus later how to set some environmental parameters.
Problem with zipping is that I don't know exact logfiles names. Each day there's a new name. So zip -q filename.zip filename.log isn't quite enough and it's impossible to use wildcards. The switch -q and checksums were welcome suggestions.
Thanks again,
Juha
Message was edited by: J.Otava -
Shell Script For Export And Import Of Table Records
Hello,
We have production and test instances and for constant testing we need to copy data from production to test or development environment.
At the moment what we do is manually doing export and import table records. At times this could be very tedious as we may need
to do this exercise a couple of times in a day.
Is it a good idea to do this exercise using shell script? If so how could I do this? If this is not a good idea what are the best alternatives?
Any input is highly appreciated.
ThanksAh I see, your company prefers stupidity over efficiency. It would be possible to do it in a controlled environment, wouldn't it? Also the test database would be allowed to select only.
So the non-allowance is just plain stupid.
To the second question: do you use hard-coded passwords in shell scripts?
Don't you think that poses a security risk?
Don't you think that is a bigger risk than a database link, properly set up?
In my book it is!
Sybrand Bakker
Senior Oracle DBA -
Shell script for export and import
Hi,
I want to run exp command in background since i need to export 40gb database of other database
if i won't use & my session will die.
appreciated any inputs.
i need to run this line from shell script.
/oracle/bin/exp pin@voipdbstg/pin file=voip.dmp owner=pin log=voip.log
bash-2.05$ more export.sh
#!/bin/sh
/oracle/bin/exp pin@voipdbstg/pin file=voip.dmp owner=pin log=voip.log
bash-2.05$ sh export.sh &
[10] 13352
bash-2.05$
Export: Release 8.1.7.0.0 - Production on Fri Dec 4 22:51:09 2009
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Password: pin
bash: pin: command not found
[10]+ Stopped sh export.sh
input appreciated
thanks
PrakashHi,
/oracle/bin/exp pin@voipdbstg/pin file=voip.dmp owner=pin log=voip.log
should be
/oracle/bin/exp pin/pin@voipdbstg file=voip.dmp owner=pin log=voip.log
Also for running the script is background and you should be able to log out of shell scriptthen run the command in nohup mode.
$nohup export.sh&
Regards -
Hi,
Let say, I have 3 parameters.
1. Script FolderPath (Remote path for e.g \\RD101\ScriptSharedFolder Here RD101 is one server)
2. Script Name(StopAllService.ps1)
3. Server Name (RD45)
I want to execute a powershell scritp in my local machine(Test1) and in that script I want to pass the above three parameters.Now I want to excute the StopAllService.ps1 script into RD45 server. But the script is available in RD101 machine.
So What I want to here How can we do this ? I have script name and script folder path and target execution server name.
Pls giude me or give me the script.
By
A Path Finder..
JoSwa
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
Best Online JournalHi,
You got 2 solutions for your problem:
1- If you have permission to run scripts in the remote computer without specifying your credential,
then, the first reply solve your problem.
2- If you have permission to run scripts in the remote computer
having to specify your credential, l then,
my solution solves your problem.
If the remote computer requires signed scripts only, you need signed script. Period. Or are you trying to break remote computer security?
If you need signed script, there's no psdrive that'll circumvent such requirement.
The problem is that the execution policy is set to "RemoteSigned". Using the URL explicitly tags that script as being from a remote source, and the policy blocks it. The PSDrive provides a local reference for the script. It does not
sign the script but the local drive reference may prevent it from being blocked for being from a remote source. I'll test that later.
Script signing is not and should never be considered a security measure. It is easily circumvented by running the script using powershell.exe, and using the -ExecutionPolicy parameter to override whatever the local execution policy setting is.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " " -
Search works differently and "wrong" in Solaris environment
I have my test and development databases in Windows and Solaris environements with exactly same database version and configurations.
I have created an intermedia index on following table as follows:
SQL>desc cc_job_offer_search_text
Name Null? Type
JOB_OFFER_ID NOT NULL NUMBER(38)
JOB_OFFER_SEARCH_TEXT NOT NULL LONG
TEXT_TYPE VARCHAR2(6)
Version for the database running in Solaris:
SQL> select * from v$version;
BANNER
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for Solaris: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
Version for the database running in Windows:
SQL> select * from v$version;
BANNER
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
Index Creation scripts:
exec ctx_ddl.drop_preference('cica_lexer');
begin
ctx_ddl.create_preference('cica_lexer','BASIC_LEXER');
ctx_ddl.set_attribute('cica_lexer','printjoins','$_#@*&^%/\()');
ctx_ddl.set_attribute('cica_lexer', 'skipjoins', '-');
end;
create index JOB_OFFER_SEARCH_TEXT_IDX on
cc_JOB_OFFER_SEARCH_TEXT(JOB_OFFER_SEARCH_TEXT)
indextype is ctxsys.context
PARAMETERS('FILTER CTXSYS.INSO_FILTER format column text_type lexer cica_lexer' );
After index has been created, my search works fine in Windows environment, however it behaves irratically in Solaris environment (where data has been exported from the database on Windows environment, and I have checked that the data is identical).
Database Running in Windows:
SQL> select count(*) from cc_job_offer_search_text;
COUNT(*)
1200
SQL> select count(*) from cc_job_offer_search_text
2 where contains(job_offer_search_text,'Permanent')>0;
COUNT(*)
1094
Database Running in Solaris:
SQL> select count(*) from cc_job_offer_search_text;
COUNT(*)
1200
SQL> select count(*) from cc_job_offer_search_text
2 where contains(job_offer_search_text,'Permanent')>0;
COUNT(*)
1200
====> In fact it returned all records, which is not correct!
However, there are certain queries which are working fine in both environments.
Database Running in Windows:
SQL> select count(*) from cc_job_offer_search_text
2 where contains(job_offer_search_text,'Contractual')>0;
COUNT(*)
52
SQL> select count(*) from cc_job_offer_search_text
2 where contains(job_offer_search_text,'{Greater than $150,000}')>0;
COUNT(*)
20
Database Running in Solaris:
SQL> select count(*) from cc_job_offer_search_text
2 where contains(job_offer_search_text,'Contractual')>0;
COUNT(*)
52
SQL> select count(*) from cc_job_offer_search_text
2 where contains(job_offer_search_text,'{Greater than $150,000}')>0;
COUNT(*)
20
Any idea why it is behaving "irratically" in the database running in the Solaris environment, when I select certain search criteria wheras it works absolutely fine at times?If you really need to run 8.1.7, you need to upgrade to the latest patchset. I seem to recall a problem like this which was fixed in something like 8.1.7.4. Better still, go to 10g.
-
Executing a unix shell script as different OS userid
Hi,
We have installed a Process server in AIX environment using redwood userid. We have scripts running under different OS userids. Please advise how to schedule a job to execute a script(KSH sctipt) to run under a different OS userid ( other than redwood userid). Thanks in advance.
Thanks.
Raj.Hi Gerben,
Thanks for the reply. My process server is running under redwood OS userid. I have a script called "ETL_EXPOERT.SH" created by the OS userid bodipadm. I want to run the script "ETL_EXPOERT.SH" as bodipadm userid. Please advise
1)What credential I have to create for bodipadm userid and what credentials I want to create for redwood userid?.
2)What credentials I want to assign to the script "ETL_EXPOERT.SH"?.
3)To which file I have to set the SETUID option for user switching ?. or where I have to setup the SETUID option?.
Thanks in advance.
Thanks.
Raj. -
[SOLVED] Simple Shell Scripting Question - Echo and Execute?
I've got a bash script which has many different commands it executes in a row. Each time the script executes one of the commands, it outputs what it is doing to the screen:
echo "cp -r home new"
cp -r home new
echo "mv testfile new/."
mv testfile new/.
I am just wondering if there is a function to execute a command and output it at the same time. Something like...
echoandexecute("cp -r home new")
echoandexecute("mv testfile new/.")
Last edited by tony5429 (2008-08-27 19:59:04)Otherwise you can define it yourself:
echoandexecute() {
echo $1
$1
echoandexecute "cp -r home new"
Last edited by catwell (2008-08-27 20:57:16) -
Why is mytimedifferentsfrom someone who is five feet away.
Go to Settings > General > Date & Time. You can set them manually, or have them automatically srt the time.
-
Wireless network (and a shell script for you guys, also)
I don't know the right way to bring up my wireless iface at bootup, so I wrote a small shell script to do it for me.
Feel free to use it if you find it useful..
I'd also appreciate someone telling me what *IS* the arch way of doing what my shell script's doing
#!/usr/bin/env bash
# Val Polyakov <[email protected]>
# 7/8/07
# Change these to reflect your network
PATH=/usr/sbin:/sbin:/bin
IFACE=ifaceNameOfYourWirelessCard
DRIVER=moduleNameForYourWirelessCard
SID=yourSID
ENCKEY=yourEncryptionKey
# Don't change anything beyond this point.
case "$1" in
start)
echo "Loading the wireless card driver"
modprobe $DRIVER
echo "Setting up the SID and encryption key"
iwconfig $IFACE essid $SID enc $ENCKEY
echo "Bringing up the wireless interface"
ifconfig $IFACE up
if [ -f /var/run/dhcpcd-$IFACE.pid ]
then
rm /var/run/dhcpcd-$IFACE.pid
fi
echo "Running the dhcp client"
dhcpcd $IFACE
stop)
echo "Bringing down the wireless interface"
ifconfig $IFACE down
echo "Unloading the driver"
rmmod $DRIVER
restart)
$0 stop
sleep 2
$0 start
echo "usage: $0 {start|stop|restart}"
esac
exit 0brain0 wrote:If your wireless drivers support wpa_supplicant, you could try autowifi from http://www.archlinux.org/~thomas/autowifi-svn/ It handles multiple wireless networks very well. There is no documentation right now, just read here: http://archlinux.org/pipermail/arch-dev … 00867.html
what would the benefit of that be, as compared to my script ?
the shell script i made (and pasted) works just fine, sits in /etc/rc.d and is called by /etc/rc.conf
i was just curious whats the official, i guess, way to do it with arch
since network profiles dont work for some reason, i figured i must be missing something.. -
Xgettext for perl and shell scripts on Solaris 9
Hi......I have to internationalized perl and shell scripts on Linux and Solaris 9.
I have used gettext on linux to internationalized both perl and shell scripts but on solaris i m not able to
achieve the same.
If we see help of xgettect on Linux, it shows input file options for Perl, Shell, C, C++ etc but help for
xgettext on Solaris shows input file option for C only.
Can you please provide me some way of using xgettext for perl and shell scripts on Solaris 9 or
is there any other way of internationalizing perl and shell scripts on Solaris 9.
Many Thanks,
LokeshSignature link blocked.
db
Contentprise wrote:
Hi......I have to internationalized perl and shell scripts on Linux and Solaris 9.
I have used gettext on linux to internationalized both perl and shell scripts but on solaris i m not able to
achieve the same.
If we see help of xgettect on Linux, it shows input file options for Perl, Shell, C, C++ etc but help for
xgettext on Solaris shows input file option for C only.
Can you please provide me some way of using xgettext for perl and shell scripts on Solaris 9 or
is there any other way of internationalizing perl and shell scripts on Solaris 9.
Many Thanks -
Shell scripts producing core dumps
I have a shell script (written in ksh) which runs fine on one solaris system, but produces a core dump on another (same version of the OS).
What is strange is that when I did a "file core", it reports the core file as generated by the shell script itself!
I didn't think it was possible for a shell script to core dump. Or if it does, file should report that the core was produced by the shell or some other program that the script calls.
Strangely enough when I introduce another "echo" statement in the for loop where the core dump occurs, the problem goes away.
Has anyone seen this behavior and know why this is happening, and why a shell script can core dump?Indeed I had the same suprise recently with ksh :
core file = core -- program ``ksh'' on platform SUNW,Sun-Fire-880
SIGSEGV: Segmentation Fault
The script was used to lauch and monitor about 40 parallel database extraction process and used signal as a mean of communication between father and child. The script behave differently without any modification in the code. ksh -n didn't report any error. Since we change to a more classic but less fancy mean of coordination, a file, the problem disepeared.
Have you consider using ksh93 (/usr/dt/bin/dtksh) intead of ksh88 (/bin/ksh) ?
Maybe you can use a debugger to get more info or truss the script.
If you get more info please update this thread, I would very much like to understand what king of thing should be considered hazardous when writing script.
Cheers
Maybe you are looking for
-
SAP EP calling ASP screen - asking multiple logon prompt from internet
Hi, We have EP page which calls multiple ASP page from the IIS server. When the users are in internet the system prompt for multiple prompt from the IIS server. 1. May i know to make it as a single logon 2. is it possible to do SSO between IIS and EP
-
DBI Reports Using PL/SQL Procedure
Hi all, Is there anyone who worked on Creating a DBI report using a PL/SQL Procedure. I want to customize a Report that is using Data Source as of type PL/SQL Procedure. Please Reply to me If anyone has any Idea on this.. Thanks in Advance..
-
How do I remove multiple apps from iPad
I have a laptop that both my son and I use which has iTunes on but has 2 accounts ie my son's and mine. When I set up my iPad 3 I transferred my apps across from my iPhone via the iTunes laptop but I appear to have also transferred across my son's ap
-
Data Recovery Options: URGENT
Here's what happened. I was in the middle of backing up my iBook. I deleted my old backup file and was replacing it with a new one. The backup got interrupted (about a week ago), and I didn't have a chance to restart the process. Then, my computer wa
-
Printing pop-ups and hidden layers
I have a pdf document with multiple layers that only pop-up when you click on the corresponding button. Since I planned on distributing this pdf to different people, I wanted to see if there was a way that users could print a printer-friendly version