Sponsored Content
Top Forums Shell Programming and Scripting problem with sudo su and .sh script Post 302158153 by cleansing_flame on Monday 14th of January 2008 02:03:43 PM
Old 01-14-2008
problem with sudo su and .sh script

here is my script:

#!/bin/sh


cd /Users/a

echo "what is the name of the file u want?"
read var1
var1=$var1
var3=$var1

echo "is this $var1 okay?"
echo "enter the type of file u want"
echo "your choices are .java, .c, .sh, .ksh, .csh"
read var2
var2=$var2

var4=`find . -type f | grep "$var1$var2" | wc -l`
var5=0

if test $var4 -ne $var5
then
echo "next "$var2" prog"
exit 0
fi

if test "$var1$var2" = "$var3.java"
then
cd /Users/a/Javaprogs
mkdir ./$var1.java
emacs /Users/a/Javaprogs/$var1.java/$var1.java
cat ../defaults/javadefaultfile.txt >> ./Javaprogs/$var1.java/$var1.java
exit 0
fi

if test "$var1$var2" = "$var3.c"
then
cd /Users/a/cprogs
mkdir ./$var1.c
emacs /Users/a/cprogs/$var1.c/$var1.c
cat ../default/cprogdefaultfile.txt >> /Users/la/cprogs/$var1.c/$var1.c
exit 0
fi


if test "$var1$var2" = "$var3.sh"
then
`sudo su`
cd /bin
mkdir ./$var1
emacs ./$var1/$var1.sh
cat /Users/a/defaults/shdefaultfile.txt >> ./$var1/$var1.sh
exit 0
fi


the part in red contains the problem, the `sudo su` command does prompt me, but once I enter my passwd i change prompt as normal. I can type, but no commands are recognized and ctrl-c does nothing but enter a new blank line. Any help would be appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HOw can i use sudo in a script

Hi Everyone, i am writing a script which will display all channels as below sudo /usr/bin/su - mycamqrd chs I kept the above two lines in a ksh and after ran that it is going to mycamqrd home dir(sudo /usr/bin/su - mycamqrd).. The script is coming out and it is not executing chs. Please... (5 Replies)
Discussion started by: rajesh212512
5 Replies

2. UNIX for Advanced & Expert Users

Sudo command problem

Hi All, I am tring to redirect mails comming to my user id to a script. In other word trigger a script when a mail comes to my user id. Actually , Admin team has done all this to me previously. in my script i am doing like /usr/local/bin/sudo -u parbrxs /export/home/parbrxs/bin/parbrxs.sh... (4 Replies)
Discussion started by: mindtee_abhi
4 Replies

3. Shell Programming and Scripting

shell script problem , sudo mount command

cat test.sh sudo mount -t vfat /dev/sda7 /media/Ddrive If i double click the test.sh file and select run in terminal then the terminal prompts for password. How can i avoid typing password? Or if i double click test.sh file and select run then nothing happens. What i'm trying "Double... (3 Replies)
Discussion started by: cola
3 Replies

4. Linux

Sudo Problem?

Hi I wanted to add a group using 1 id which is not root but has some sudo privileges. test@test>sudo -l gives this (root) NOPASSWD: /usr/bin/passwd, /usr/sbin/useradd, /usr/sbin/usermod, /usr/sbin/userdel, /usr/bin/tee, /usr/bin/grep, /bin/grep, /usr/bin/chmod, /bin/chmod, /usr/bin/echo,... (1 Reply)
Discussion started by: datkan
1 Replies

5. Solaris

Problem with password expire and sudo.

Hi, I have a small problem that I need to address regarding the password expiration for a number of different oracle accounts. Currently I have the MAXWEEKS set to 12 in the /etc/default/passwd file for all accounts. I also have sudo installed on the server and users access the oracle accounts... (2 Replies)
Discussion started by: sparcman
2 Replies

6. UNIX for Dummies Questions & Answers

Problem with Sudo inside a here document

Have a sudo statement inside of a here document. It prompts me for a password, but doesnt wait for me to enter my password. Is there a way I can use the command without sudo or anyway that I can enter the password correctly? Eg : while read remotehost do ssh -t $2@$remotehost ... (0 Replies)
Discussion started by: mnanavati
0 Replies

7. UNIX for Advanced & Expert Users

sudo wildcards problem: for every argument a *-wildcard? Better solution?

Hi I allow the user tommy to run this command as root sudoCommand: /app/appname/connectors/*/*/current/bin/*With "sudo -l" he sees the sudoers, but is unable to execute. $ sudo /app/appname/connectors/zur/namename/current/bin/othername agentsvc --i --u root --sn 1m7command Sorry, user... (2 Replies)
Discussion started by: slashdotweenie
2 Replies

8. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

9. Shell Programming and Scripting

Problem connect to a different server then do sudo login and finally run some scripts and get result

I have to write a shell script in my current linux server and I have to connect to a different server then do sudo login and finally run some scripts residing in a particular directory and get results back. I am starting to write my shell script as below but after I do ssh login it prompts for... (2 Replies)
Discussion started by: Devesh5683
2 Replies

10. HP-UX

Problem using sudo with NOPASSWD

I need to configure access for a user in an HP-UX to : 1) use certain commands and 2) login as another user as a sudo. These have to be done WITHOUT the user needing to enter a password. However, after I enter the lines using visudo, there is a prompt for a password when the user... (3 Replies)
Discussion started by: aigini82
3 Replies
MYSQLI_STMT(3)								 1							    MYSQLI_STMT(3)

The mysqli_stmt class

INTRODUCTION
Represents a prepared statement. CLASS SYNOPSIS
mysqli_stmt mysqli_stmt Properties o int$mysqli_stmt->affected_rows o int$mysqli_stmt->errno o array$mysqli_stmt->error_list o string$mysqli_stmt->error o int$mysqli_stmt->field_count o int$mysqli_stmt->insert_id o int$mysqli_stmt->num_rows o int$mysqli_stmt->param_count o string$mysqli_stmt->sqlstate Methods o mysqli_stmt::__construct (mysqli $link, [string $query]) o int mysqli_stmt::attr_get (int $attr) o bool mysqli_stmt::attr_set (int $attr, int $mode) o bool mysqli_stmt::bind_param (string $types, mixed &$var1, [mixed &$...]) o bool mysqli_stmt::bind_result (mixed &$var1, [mixed &$...]) o bool mysqli_stmt::close (void ) o void mysqli_stmt::data_seek (int $offset) o bool mysqli_stmt::execute (void ) o bool mysqli_stmt::fetch (void ) o void mysqli_stmt::free_result (void ) o mysqli_result mysqli_stmt::get_result (void ) o object mysqli_stmt::get_warnings (mysqli_stmt $stmt) o mixed mysqli_stmt::prepare (string $query) o bool mysqli_stmt::reset (void ) o mysqli_result mysqli_stmt::result_metadata (void ) o bool mysqli_stmt::send_long_data (int $param_nr, string $data) o bool mysqli_stmt::store_result (void ) PHP Documentation Group MYSQLI_STMT(3)
All times are GMT -4. The time now is 01:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy