473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to switch user while executing the script

4
Hi guys,

In my script, I need to switch to another user to execute a command which I don't have the privilege to run. Actually the script copies a file from one directory to another. The script running user doesn't have the permission in target directory. So I need to switch to another user for the same. I tried 'su' command in unix.But it failed to accept the password.evenif I echo the password its prompting again for the password when it executes. Is there any way to achieve this functionality?.... Please help

Thanks in advance,

Vipin C
Jul 17 '07 #1
10 6154
numberwhun
3,509 Expert Mod 2GB
Unfortunately, there is no way to do this in a Perl script. I know, I had this though quite a while ago when I was working on a script that needed to do stuff as two different users. The only way to do it is to create a script for each user to kick off, to do the tasks they need to.

Regards,

Jeff
Jul 17 '07 #2
vipinc
4
Thanks Jeff...

But the issue here is, Iam calling the script from one of my informatica workflows. When informatica executes the script it executes as a particular user which we can't change. That why we thought of switch user in the script method....Can you put some light on this issue..

Thanks in advance

Vipin C
Jul 17 '07 #3
numberwhun
3,509 Expert Mod 2GB
Unfortunately, I know nothing about Informatica or its workflows, so I cannot even begin to comment on that. What I do know is that if you need some tasks done by a script, those tasks will be completed by the user account that kicks off the script. I am not sure how you are going to solve your problem, especially in an automated fashion as it looks like you are trying to do it.

Regards,

Jeff
Jul 17 '07 #4
miller
1,089 Expert 1GB
Hi guys,

In my script, I need to switch to another user to execute a command which I don't have the privilege to run. Actually the script copies a file from one directory to another. The script running user doesn't have the permission in target directory. So I need to switch to another user for the same. I tried 'su' command in unix.But it failed to accept the password.evenif I echo the password its prompting again for the password when it executes. Is there any way to achieve this functionality?.... Please help

Thanks in advance,

Vipin C
Best solution: Simply update the permissions of the directory the script needs access to.

Perlish Solution: Whenever you need to interact with the system in more than a single command type way, use the Expect module.

cpan Expect

It will let you type a password exactly when the su command prompts for it.

- Miller
Jul 17 '07 #5
numberwhun
3,509 Expert Mod 2GB
How will the Expect module be effected if he cannot change the directories permissions? For what I was working on when I had this issue, the directories permissions could not be modified as they were needed the way they were ( for security reasons).

The only thing I can think of in that situation is maybe getting yourself added to the group that has rights to execute in those directories, if possible.

Regards,

Jeff
Jul 17 '07 #6
miller
1,089 Expert 1GB
The Expect module lets you automate anything that you would normally do from the command prompt. Basically it lets you interact with the system in any situation where it "expects" a human. Such as a prompt for a password.

The module itself advocates against such usage, as it's unsecure. However, it suggest alternatives, such as using "sudo" instead of "su". Which is better security practice anyway.

- Miller
Jul 17 '07 #7
vipinc
4
Thanks Miller and Jeff.......

I have tried those options too....but since its a secure server, they won't allow adding the user to a group which have the permissions. Also sudo won't work since that utility or module is not available in the server..I don't know much about the EXPECT module in Perl....Miller,How can I check whether this EXPECT module is available in the server?.....It would be a great help in that case.

Thanks in advance,

Vipin
Jul 18 '07 #8
vipinc
4
Again failure...it seems EXPECT module is not installed in the machine...and they are not ready to install it because of security reasons..

Miller / Jeff,..Whats next???? :-(

Thanks,

Vipin C
Jul 18 '07 #10
numberwhun
3,509 Expert Mod 2GB
Again failure...it seems EXPECT module is not installed in the machine...and they are not ready to install it because of security reasons..

Miller / Jeff,..Whats next???? :-(
Unfortunately, dealing with situations like this is never easy. It looks to me like you are going to have a fight on your hands to either get the needed module(s) installed or get permissions changed, just so you can do what you need to do.

With projects of this nature, dealing with things that "HAVE" to get done and in a secure environment, sometimes you end up reaching that brick wall that both parties are pushing on. On one side is the developer saying "I need this to do my job" and on the other is the business saying "Get this done and working now!". You almost have to take center stage and make sure everyone knows that THIS is where you stand in your project and either one of THESE two things happens or the project will not be able to be completed. Heck, even throw out the idea that the "deadline will not be met". That is always a good one.

Either way, I wish you luck. If it turns out that they give you either or and you need additional help, be sure to let us know and we will do what we can.

Regards,

Jeff
Jul 18 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: JaNE | last post by:
I'm trying to get some data from MySql database and to create switch based on those data, but as an php beginer, I have no clear idea how to do this. have tryed many options which loked promising,...
6
by: Jeff Duffy | last post by:
Hi all. I've been wondering why python itself doesn't provide a switch to check a file for valid syntax. I know that you can currently call python -c "import py_compile;...
2
by: Oliver | last post by:
I've been looking for information regarding this and all i can gather is posters informing posties to use $< and $>. However, i can't seem to find an example on how to apply that. Information...
2
by: Christopher Jedlicka | last post by:
I am trying to write a script that will access files on another computer on the network but in a seperate domain. In order to access the files, I need to first authenticate to the other domain as...
23
by: ern | last post by:
I have a program that runs scripts. If the user types "script myScript.dat" the program will grab commands from the text file, verify correctness, and begin executing the script UNTIL... I need...
19
by: rdavis7408 | last post by:
Hello, I have four textboxes that the user enters the price per gallon paid at the pump, the mileage per gallon and I would like to then calculate the cost per gallon and use a switch statement to...
6
by: William Pierce | last post by:
Hi, I have an interesting problem that I am stuck on and was wondering if there might be others who can shed some light.... Basically, within an HTML page, I have a tag that looks as...
1
by: s99999999s2003 | last post by:
hi due to certain constraints, i will running a python script as root inside this script, also due to some constraints, i need to switch user to user1 to run the rest of the script...is there a...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.