Bypass Read Line in profile through AIX command


 
Thread Tools Search this Thread
Operating Systems AIX Bypass Read Line in profile through AIX command
# 1  
Old 02-14-2014
IBM Bypass Read Line in profile through AIX command

Hi All,

I have a complicated requirement where in I have a "root" user and a user named "xeadmin" I want to take sudo of "xeadmin" by command sudo su - xeadmin. Later i need to hit 2 enter keys as there are 2 read line commands inserted in profile of "xeadmin" and I reach command prompt, i need to execute a command "initializexeservice -y start" I want to get this executed in one scipt like
sudo su - xeadmin;Enter;Enter;initializexeservice -y start but "Enter" do not work form me. I am not allowed to make the changes in profile. I want to execute this command replacing Enter whith proper executable command.

Please let me know how to achieve this. It is fine if i need to execute any external script through root, keeping in mind I do not change any permissions or any other system parameters.

Thanks In Advance

Regards
Hitesh Sathawane
# 2  
Old 02-14-2014
These cases happen often... when you have not anticipated that that particular user can be used for batches...
I usually modify the users .profile by testing if you are using a interactive shell or not and adapt the code:
Code:
if [[ $- = *i* ]]; then
  # interactive mode, put here what is specific to
  # Like stty settings, keyboard stuff etc.. e.g.
    export PS1="$(hostname):\$PWD \$ "
    set -o vi
    stty erase ^?
fi

I let you adapt for your needs...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to bypass rm command when there are no files to delete?

Hi, Below command works fine when we have other files apart from hello.txtls | ggrep -v hello* | xargs rm -rfBut, if there is only one file i.e hello.txt the rm command does not find anything to delete and the script hangs. While there could be trivial ways to check using if conditions if... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. Shell Programming and Scripting

How to read the output of a command line by line and pass it as a variable?

Hi, I have some 2000 names in a table like below. Java Oracle/SQL ANSI SQL SQL,DWH,DB DB&Java And by using for loop in my code i am able to get a single word but if there is any special character or space then it is considering as a next line. I have to execute the below queries in... (10 Replies)
Discussion started by: Samah
10 Replies

3. Shell Programming and Scripting

Read line by line and execute command

Hi ALL, I have a requirement like this. 1.GET ALL TABLE NAME (just table name) keep in file 2.Read line by line and get the count of table from tablename files. tablename detail has a sql statement "db2 select tabname from syscat.tables" (1 Reply)
Discussion started by: netdbaind
1 Replies

4. Shell Programming and Scripting

Error to Read Input from command line

Team , I am trying to write a case condition for database backups.But I am unable to make the script to read input from command line . while true ;do read -p "Do You Wish To Take Database Backup ?? " yn case $yn in *) echo " YES take backup ";; *) echo " NO BACKUP " ;; ... (9 Replies)
Discussion started by: rocking77
9 Replies

5. Shell Programming and Scripting

Need help to read command line arguments?

I am new to schell scripting . My objective is to write a ksh shell script that performs following tasks: - 1. Script reads all command line arguments (arguments are file names) and checks if it contains charachters "abc" in it. 2. If it contains "abc" it will execute a binary file xyz <command... (3 Replies)
Discussion started by: acmilan
3 Replies

6. Shell Programming and Scripting

Multi Line 'While Read' command issue when using sh -c

Hi, I'm trying to run the following command using sh -c ie sh -c "while read EachLine do rm -f $EachLine ; done < file_list.lst;" It doesn't seem to do anything. When I run this at the command line, it does remove the files contained in the list so i know the command works ie... (4 Replies)
Discussion started by: chrispward
4 Replies

7. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

8. Shell Programming and Scripting

read command line as it is

I want to read the command line as it is in the script. say prompt$ a.sh 'inst_cont_Header__dss -v '" 0"' -m' i want to use 'inst_cont_Header__dss -v '" 0"' -m' as it is, inside the scripts a.sh. I've tried $@ "$@" $* "$*" but all of these in some way or other... (8 Replies)
Discussion started by: ajitkumar2
8 Replies

9. OS X (Apple)

creating a new profile from command line

Does any1 know how to preform such an operation on a mac? any help appreciated (2 Replies)
Discussion started by: cleansing_flame
2 Replies

10. Programming

command line socket read utility

HI I have a messaging s/w daemon(TIBCO rvrd) provided by vendor which will accept connections from various clients and routes messages to the destinations. In order to route it internally uses two ports(one tcp adn one udp). I want to know on which port(tcp/udp) it is transmitting... (3 Replies)
Discussion started by: axes
3 Replies
Login or Register to Ask a Question