Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Expect command to switch user Post 302322680 by sysgate on Thursday 4th of June 2009 10:06:47 AM
Old 06-04-2009
No, when you enclose something in quotes, Expects takes it as literal string, instead, you should use wildcard, as in :
expect "*assword" - with case sensitivity in mind
or just 'expect assword:' without the quotes.
This User Gave Thanks to sysgate For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Non-interactive user switch to root

Is is possible switch user from a non-root user to root user without entering the password interactively inside a korn shell script which is run by a non-root user? e.g. I have a non-root user called infodba who is in dba group and I want to create a shell script which is executed by infodba... (5 Replies)
Discussion started by: stevefox
5 Replies

2. Shell Programming and Scripting

Expect help/interaction with switch..

Hi All, I have been trying to get an Expect program to communicate with a Remote Power Switch which will eventually log in, and then turn on/off certain outlets. For some reason, I can't get through the log in procedure with this Switch. When you first spawn the telnet, you get the Switch... (1 Reply)
Discussion started by: mrjgs70
1 Replies

3. Shell Programming and Scripting

Switch to different user without expect

Hi, I have to switch to a different user and execute certain commands and then come back to the original user Ex: My id is 'usstage'. I need to switch to 'apstage', souce a script there, execute a function and then get back again to usstage. Please note that I do not have expect installed... (4 Replies)
Discussion started by: sugan
4 Replies

4. AIX

Switch user(su) two times

Is it possible to switch to root(if allowed) and then with root privileges switch to another user account "ABC"? To further explain the scenario, ABC is an account which has sugroups=su2DEF and root is not part of su2DEF group. but, given that root can switch to any account(correct me if I am... (7 Replies)
Discussion started by: mtwain
7 Replies

5. Shell Programming and Scripting

switch as another user without password

I want to switch as another user without using password .Is it posiible ? I have one server B and I have logged in as username u1 but I want to login to that same server using username as u2 but I don't want to give the password for u2. (3 Replies)
Discussion started by: maitree
3 Replies

6. Shell Programming and Scripting

switch user from local user to root in perl

Hi Gurus, I have a script that requires me to switch from local user to root. Anyone who has an idea on this since when i switch user to root it requires me to input root password. It seems that i need to use expect module here, but i don't know how to create the object for this. ... (1 Reply)
Discussion started by: linuxgeek
1 Replies

7. Shell Programming and Scripting

using expect to switch users in a script

hi, I need to switch users in a script I'm newbee to expect I wrote two files 1 sudo.exp, since su4098 is used as root in my laptop #!/usr/bin/expect spawn su su4098 expect *Password:* send mypsw\n interact 2 test.sh ls ./sudo.exp tcpdump -i wlan0 su esolve ls however, in... (1 Reply)
Discussion started by: esolve
1 Replies

8. Shell Programming and Scripting

Switch user terminal error

Hello All, Here I am trying to login a Linux machine as admin user from a Solaris box.. & then switch to root user.. Code I use: ssh admin@<IP> << END su - root << A echo "Hello I am logged in as root" exit A exit END But the error I get.. su: must be run from a... (3 Replies)
Discussion started by: ailnilanjan
3 Replies

9. Shell Programming and Scripting

How to Switch from Local user to root user from a shell script?

Hi, I need to switch from local user to root user in a shell script. I need to make it automated so that it doesn't prompt for the root password. I heard the su command will do that work but it prompt for the password. and also can someone tell me whether su command spawns a new shell or... (1 Reply)
Discussion started by: Little
1 Replies

10. Shell Programming and Scripting

Expect command to send the user input enter or ctrl+c

Hey All, I am writing one script using expect, that script which is used in spawn will accepts only 1. Enter 2. Ctrl+c Press Control-C to exit, Enter to proceed. Could some one share some thoughts to send the above user inputs in linux expect block ? Thanks, Sam (0 Replies)
Discussion started by: SCHITIMA
0 Replies
FTP-UPLOAD(1p)						User Contributed Perl Documentation					    FTP-UPLOAD(1p)

NAME
ftp-upload - batch transfer local files to an FTP server SYNOPSIS
ftp-upload [any-switch]... {[repeatable-switch]... file...}... DESCRIPTION
ftp-upload is used to send local files to an FTP server. It isn't interactive, it's meant to be used from scripts. It is disciplined about its exit value and it doesn't output informational messages by default. There are two kinds of switches. Initial switches have to appear before any filenames, they affect the session as a whole. Repeatable switches can appear interspersed with the file names, they affect the transfer of the files which appear after them on the command line. OPTIONS
Initial switches These have to be used before any file names listed on the command line. --debug Turn debugging on. --help Show the usage message and die. --ignore-quit-failure Don't complain or set a failure exit code just because the QUIT command fails. This can be necessary because some servers, in blatant disregard of RFC 959, close the command channel when you send them an ABOR command. -v, --verbose Print informational messages to stdout. --version Show the version number and exit. Initial switches which specify connection information These also have to be used before any file names listed on the command line. They specify the information used to set up the FTP connec- tion. --account account This specifies the account to be used when logging into the remote system. This is distinct from the user name used to log in. Few systems need this. There is no default. -h, --host host Specify the host to which to connect. There is no default, you have to specify this switch. --passive Force the use of passive (PASV) transfers. Passive transfers are required with some firewall configurations, but if you have such you'd do better to configure Net::FTP so that it knows when to use them (see Net::Config). If you need to use passive transfers with certain (broken) servers, however, this switch is your best bet. Alternatively, you can set $FTP_PASSIVE to 1 in the environment (see Net::FTP). --password pw This gives the password which will be used to login. The default is your email address. Note that you should not specify a real (secret) password this way, as on most systems anybody on the machine can see the arguments you pass to your commands. Use one of other password-setting switches instead. -s, --password-stdin This tells ftp-upload to read the password from standard input. No prompt will be printed, and a single line will be read. Most peo- ple will use this switch to specify the password. Eg, echo 3x9sjJJh | ftp-upload -sh $host -u $user $file Using echo this way is safe where the --password switch isn't if the echo command is built in to the shell. --password-fd fd This is like --password-stdin except that it reads the password from the file descriptor numbered fd. ftp-upload -h $host -u $user --password-fd=3 3<$pw_file $file -u, --user user Specify the user name to use when logging in. The default is "anonymous". Repeatable switches These switches can be used anywhere on the command line (except after the last file name). They affect the transfer of files listed after them. --as remote-name Normally a file is transferred using the same name it has locally. If you use this switch the next file transferred will be called remote-name on the other host instead. ftp-upload --host $host --as index.htm index.html -a, --ascii Perform transfers in ASCII mode. -b, --binary Perform transfers in binary mode. This is the default. -d, --dir dir Change directory to dir on the FTP server before continuing. You can use this multiple times between files, ftp-upload will chdir once for each time you specify it. Using ".." as the dir will cause an FTP "CDUP" to be done rather than a "CWD". --full-path Normally uploaded files go into the current directory on the remote host, even when the local file name given contains slashes. Eg, if you say ftp-upload -h $host /etc/motd ftp-upload will upload the file as motd, not /etc/motd. This differs from how the standard ftp program works, and it also differs with how ftp-upload worked before version 1.3. If you specify --full-path, you'll get the other behavior. A request to upload dir/file will tell the server to store dir/file rather than file. When you use --as the --full-path setting doesn't matter. --full-path only tells the program what name to use when it's choosing the name. --no-full-path Disable --full-path. This is the default. -l, --ls Try to get a remote directory listing of files after transferring them. I say "try" because there's no guaranteed way to do this with the FTP protocol. The command I run is "LIST file". This will generally work if file doesn't contain any special characters. -L, --no-ls Disable the --ls behavior. --tmp-none Transfer files directly, don't do anything special to try to ensure that they don't appear under their real names on the remote machine until the transfer is finished. Each file is transferred with a single simple "STOR". This is the default. --tmp-samedir Transfer files to the remote machine using a temporary name, then rename them when the transfer finishes. This won't work if the remote server doesn't give a recognizable response to the "STOU" command. If the server's response to "STOU" isn't recognized by Net::FTP but is reasonable, Graham Barr might be willing to change Net::FTP to recognize it. If you like you can send the "--debug" output to me and I'll coordinate such requests. --tmp-dir dir Transfer files to dir on the remote host, then rename them when the transfer is complete. This is safer than --tmp-samedir because it doesn't use "STOU" and so it works with more servers. ftp-upload -h $host --tmp-dir incoming $file --tmp-format fmt Transfer files to "sprintf(fmt, file base name)", then rename them when the transfer is complete. Like --tmp-dir, this is safer than --tmp-samedir because it doesn't use "STOU" and so it works with more servers. ftp-upload -h $host --tmp-format tmp.%s $file AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.8.7 2006-03-16 FTP-UPLOAD(1p)
All times are GMT -4. The time now is 09:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy