great! that works. but i have another problem. i'm using prompt in secured way as "read -s -t 10" but I need to store the output in one variable. as below. but nothing is storing in $req variable
#!/bin/csh set pass=`cat file | grep rootpw | grep -o '".*"' | sed 's/"//g'` if ( "$pass" == "edjos" ) then echo "You are at default password. kindly change the password in 10secs……." set req=`bash -c 'read -s -t 10'` echo $req if ( "$req" == "" ) then echo "No password entered. So continuing with default password" else sed -i.bak "/rootpw/s/edjos/$req/" file endif endif On Mon, Mar 8, 2021 at 4:02 PM Richard L. Hamilton <rlha...@smart.net> wrote: > If it has to be pure csh (without any helpers), you're probably out of > luck, because csh is crippled when it comes to scripting. > > You could probably use a command substitution on a one-liner of your bash > from the csh script: > > #! /bin/csh > set myvar=`bash -c 'read -t 10 ;echo "${REPLY}"'` > echo "$myvar" > > For anything much trickier, getting the quoting right will be a killer, so > the helper should probably be a separate bash script. > > Picking csh to script it is just wrong, because it has too many missing > capabilities, isn't predictable enough in how it behaves, doesn't > necessarily behave as portably as other shells, etc. > http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ < > http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/> > > > > On Mar 8, 2021, at 04:38, Thebest videos <sri.chityala...@gmail.com> > wrote: > > > > > > hi Team, > > > > Im trying create a csh script. > > requirement: > > when i script runs it asks for user input. prompt should wait for 10secs. > > if not then exit the script. > > i have solution for bash script where i can use read -t 10 username. but > i > > want same in csh > > ``` > > #!/bin/csh > > echo -n "username:" > > set req = $< > > echo "username is $req" > > sed -i.bak "/rootpw/s/edjos/$req/" /boot/loader.conf > > ``` > > and for advance level, the message should look like "prompts end in > 10(this > > number should decrease and lively should visible the timeout secs)" > > _______________________________________________ > > openindiana-discuss mailing list > > openindiana-discuss@openindiana.org > > https://openindiana.org/mailman/listinfo/openindiana-discuss > > > > _______________________________________________ > openindiana-discuss mailing list > openindiana-discuss@openindiana.org > https://openindiana.org/mailman/listinfo/openindiana-discuss > _______________________________________________ openindiana-discuss mailing list openindiana-discuss@openindiana.org https://openindiana.org/mailman/listinfo/openindiana-discuss